-
Notifications
You must be signed in to change notification settings - Fork 143
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(git): add support to only fetch repositories #918
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -197,6 +197,8 @@ pub struct Git { | |||||||||||||||||
repos: Option<Vec<String>>, | ||||||||||||||||||
|
||||||||||||||||||
pull_predefined: Option<bool>, | ||||||||||||||||||
|
||||||||||||||||||
fetch_only: Option<bool>, | ||||||||||||||||||
} | ||||||||||||||||||
|
||||||||||||||||||
#[derive(Deserialize, Default, Debug, Merge)] | ||||||||||||||||||
|
@@ -1050,6 +1052,11 @@ impl Config { | |||||||||||||||||
self.config_file.git.as_ref().and_then(|git| git.arguments.as_ref()) | ||||||||||||||||||
} | ||||||||||||||||||
|
||||||||||||||||||
/// Only fetch repo's instead of pulling | ||||||||||||||||||
pub fn git_fetch_only(&self) -> Option<&bool> { | ||||||||||||||||||
self.config_file.git.as_ref().and_then(|git| git.fetch_only.as_ref()) | ||||||||||||||||||
} | ||||||||||||||||||
Comment on lines
+1055
to
+1058
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If a default value is given, we can:
Suggested change
|
||||||||||||||||||
|
||||||||||||||||||
pub fn tmux_config(&self) -> Result<TmuxConfig> { | ||||||||||||||||||
let args = self.tmux_arguments()?; | ||||||||||||||||||
Ok(TmuxConfig { | ||||||||||||||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -295,16 +295,24 @@ impl RepoStep { | |
async fn pull_repo<P: AsRef<Path>>(&self, ctx: &ExecutionContext<'_>, repo: P) -> Result<()> { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's update the function name and its doc as well: /// Try to pull a repo, or fetch it if `fetch_only` is enabled.
async fn pull_or_fetch_repo<P: AsRef<Path>>(&self, ctx: &ExecutionContext<'_>, repo: P) -> Result<()> { |
||
let before_revision = get_head_revision(&self.git, &repo); | ||
|
||
if ctx.config().verbose() { | ||
println!("{} {}", style("Pulling").cyan().bold(), repo.as_ref().display()); | ||
} | ||
|
||
let mut command = AsyncCommand::new(&self.git); | ||
|
||
command | ||
.stdin(Stdio::null()) | ||
.current_dir(&repo) | ||
.args(["pull", "--ff-only"]); | ||
if ctx.config().git_fetch_only().is_some_and(|f| *f) { | ||
if ctx.config().verbose() { | ||
println!("{} {}", style("Fetching").cyan().bold(), repo.as_ref().display()); | ||
} | ||
|
||
command.stdin(Stdio::null()).current_dir(&repo).args(["fetch"]); | ||
} else { | ||
if ctx.config().verbose() { | ||
println!("{} {}", style("Pulling").cyan().bold(), repo.as_ref().display()); | ||
} | ||
|
||
command | ||
.stdin(Stdio::null()) | ||
.current_dir(&repo) | ||
.args(["pull", "--ff-only"]); | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looks like the submodule update procedure should also be considered as a part of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's update
|
||
|
||
if let Some(extra_arguments) = ctx.config().git_arguments() { | ||
command.args(extra_arguments.split_whitespace()); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we give this config a default value
false
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BTW, for all the docs under
[git]
, we need to update them,pull or fetch