fetch_remote setting to disable remote repo updates

This commit is contained in:
Trevor Bentley
2023-01-26 01:30:20 +01:00
parent 08b075e29d
commit f89f44b340
3 changed files with 39 additions and 15 deletions
+14
View File
@@ -159,6 +159,20 @@ syntax_highlight = true
# #
syntax_highlight_theme = "base16-ocean.light" syntax_highlight_theme = "base16-ocean.light"
# Whether or not to run 'git fetch' on remote repos
#
# When specified repositories are remote (via HTTPS), this setting
# configures whether Itsy-Gitsy should run the equivalent of `git
# fetch --all` to update the repository first.
#
# Itsy-Gitsy will exit with an error if the fetch fails. If a
# repository is not available, or if Itsy-Gitsy is running in an
# environment without network access, this should be set to 'false'.
#
# This can also be set per-repository. Defaults to 'true' if not
# specified.
fetch_remote = true
# Number of threads to use for parallel processing # Number of threads to use for parallel processing
# #
# Specify a specify a specific number of threads/cores to split # Specify a specify a specific number of threads/cores to split
+20 -15
View File
@@ -149,21 +149,26 @@ impl GitsyGenerator {
.collect(); .collect();
match Repository::open(&clone_path) { match Repository::open(&clone_path) {
Ok(r) => { Ok(r) => {
// Repo already cloned, so update all refs match self.settings.fetch_remote {
let refs: Vec<String> = r Some(false) => {}
.references() _ => { // explicitly true, or unspecified (default)
.expect(&format!("Unable to enumerate references for repo [{}]", name)) // Repo already cloned, so update all refs
.map(|x| { let refs: Vec<String> = r
x.expect(&format!("Found invalid reference in repo [{}]", name)) .references()
.name() .expect(&format!("Unable to enumerate references for repo [{}]", name))
.expect(&format!("Found unnamed reference in repo: [{}]", name)) .map(|x| {
.to_string() x.expect(&format!("Found invalid reference in repo [{}]", name))
}) .name()
.collect(); .expect(&format!("Found unnamed reference in repo: [{}]", name))
r.find_remote("origin") .to_string()
.expect(&format!("Clone of repo [{}] missing `origin` remote.", name)) })
.fetch(&refs, None, None) .collect();
.expect(&format!("Failed to fetch updates from remote repo [{}]", name)); r.find_remote("origin")
.expect(&format!("Clone of repo [{}] missing `origin` remote.", name))
.fetch(&refs, None, None)
.expect(&format!("Failed to fetch updates from remote repo [{}]", name));
},
}
clone_path.to_string_lossy().to_string() clone_path.to_string_lossy().to_string()
} }
Err(_) => { Err(_) => {
+5
View File
@@ -364,6 +364,7 @@ pub struct GitsySettingsRepo {
pub render_markdown: Option<bool>, pub render_markdown: Option<bool>,
pub syntax_highlight: Option<bool>, pub syntax_highlight: Option<bool>,
pub syntax_highlight_theme: Option<String>, pub syntax_highlight_theme: Option<String>,
pub fetch_remote: Option<bool>,
pub attributes: Option<BTreeMap<String, toml::Value>>, pub attributes: Option<BTreeMap<String, toml::Value>>,
pub paginate_history: Option<usize>, pub paginate_history: Option<usize>,
pub paginate_branches: Option<usize>, pub paginate_branches: Option<usize>,
@@ -406,6 +407,7 @@ pub struct GitsySettings {
pub readme_files: Option<Vec<String>>, pub readme_files: Option<Vec<String>>,
pub asset_files: Option<Vec<String>>, pub asset_files: Option<Vec<String>>,
pub branch: Option<String>, pub branch: Option<String>,
pub fetch_remote: Option<bool>,
pub paginate_history: Option<usize>, pub paginate_history: Option<usize>,
pub paginate_branches: Option<usize>, pub paginate_branches: Option<usize>,
pub paginate_tags: Option<usize>, pub paginate_tags: Option<usize>,
@@ -491,6 +493,7 @@ impl GitsySettings {
global_to_repo!(settings, repo, render_markdown); global_to_repo!(settings, repo, render_markdown);
global_to_repo!(settings, repo, syntax_highlight); global_to_repo!(settings, repo, syntax_highlight);
global_to_repo!(settings, repo, syntax_highlight_theme); global_to_repo!(settings, repo, syntax_highlight_theme);
global_to_repo!(settings, repo, fetch_remote);
global_to_repo!(settings, repo, paginate_history); global_to_repo!(settings, repo, paginate_history);
global_to_repo!(settings, repo, paginate_branches); global_to_repo!(settings, repo, paginate_branches);
global_to_repo!(settings, repo, paginate_tags); global_to_repo!(settings, repo, paginate_tags);
@@ -533,6 +536,7 @@ impl GitsySettings {
render_markdown: settings.render_markdown.clone(), render_markdown: settings.render_markdown.clone(),
syntax_highlight: settings.syntax_highlight.clone(), syntax_highlight: settings.syntax_highlight.clone(),
syntax_highlight_theme: settings.syntax_highlight_theme.clone(), syntax_highlight_theme: settings.syntax_highlight_theme.clone(),
fetch_remote: settings.fetch_remote.clone(),
paginate_history: settings.paginate_history.clone(), paginate_history: settings.paginate_history.clone(),
paginate_branches: settings.paginate_branches.clone(), paginate_branches: settings.paginate_branches.clone(),
paginate_tags: settings.paginate_tags.clone(), paginate_tags: settings.paginate_tags.clone(),
@@ -576,6 +580,7 @@ impl GitsySettings {
render_markdown: settings.render_markdown.clone(), render_markdown: settings.render_markdown.clone(),
syntax_highlight: settings.syntax_highlight.clone(), syntax_highlight: settings.syntax_highlight.clone(),
syntax_highlight_theme: settings.syntax_highlight_theme.clone(), syntax_highlight_theme: settings.syntax_highlight_theme.clone(),
fetch_remote: settings.fetch_remote.clone(),
paginate_history: settings.paginate_history.clone(), paginate_history: settings.paginate_history.clone(),
paginate_branches: settings.paginate_branches.clone(), paginate_branches: settings.paginate_branches.clone(),
paginate_tags: settings.paginate_tags.clone(), paginate_tags: settings.paginate_tags.clone(),