-
Notifications
You must be signed in to change notification settings - Fork 139
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?
Conversation
add `fetch_only` to config in case user wants to only fetch, not already pull changes Closes topgrade-rs#806
@@ -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 comment
The 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<()> {
@@ -196,6 +196,8 @@ | |||
# Arguments to pass Git when pulling Repositories | |||
# arguments = "--rebase --autostash" | |||
|
|||
# Whether to fetch only instead of pulling remote changes |
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
/// 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()) | ||
} |
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.
If a default value is given, we can:
/// 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()) | |
} | |
/// Only fetch repo's instead of pulling | |
pub fn git_fetch_only(&self) -> bool { | |
self.config_file.git.as_ref().and_then(|git| git.fetch_only).unwrap_or(false) | |
} |
.stdin(Stdio::null()) | ||
.current_dir(&repo) | ||
.args(["pull", "--ff-only"]); | ||
} |
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.
Looks like the submodule update procedure should also be considered as a part of git pull
?
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.
Let's update pull_repos()
function as well
- Rename it to
pull_or_fetch_repos()
- Update the doc
- Update the outputs exclusive to
git pull
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.
This should be updated as well:
Line 30 in f6d2ba4
pub fn run_git_pull(ctx: &ExecutionContext) -> Result<()> { |
Thanks for the PR, left some comments:) |
What does this PR do
add
fetch_only
to config in case user wants to only fetch, not already pull changesStandards checklist
CONTRIBUTING.md
For new steps
--dry-run
option works with this step--yes
option works with this step if it is supported bythe underlying command
If you developed a feature or a bug fix for someone else and you do not have the
means to test it, please tag this person here.