-
Notifications
You must be signed in to change notification settings - Fork 155
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
Add support for pushing custom git repositories #574
Conversation
Thanks for doing this! The core part of this PR LGTM, I have left some comments on some small things that need to be changed. I have some thoughts on the public interfaces (i.e., the config file/how users would use this feature), and I wanna hear your thoughts as well:
|
Thanks for the good comments, I've updated the ones I missed so that should be all good now. I'm also going to address your comments in reverse order: (3) Indeed, I think that's a fairly easy migration path. We could also alias (2) agreed, I guess what I meant when I said "opt in" was, "we shouldn't just start pushing any repo we find" i.e. "we should not do the new thing unless told so" so we are in agreement there. (1) I think this is a UX decision. Personally I have a slight preference for the current implementation because that works better with my workflow. I have two machienes I work across at no real defined schedule, and I have a bunch of repositories on both that need to both read and write. Think dotfiles, personal projects, prototypes, etc. Bascially I just have a projects folder and that folder is globbed into the repos so everything there I want as up to date as possible. Therefore the current impl works a bit nicer because that way I don't have to maintain essentially duplicate lists, however I'm not sure how common this workflow is, and I agree that your suggestions allows more flexibility. so tl;dr I slightly prefer my solution, but am happy to go with yours if you prefer. In any case, thanks for the guidance and thoughtful comments, contributing here has been a very pleasant experience :) |
So with the approach I suggested, your configuration file would be something like this, right? [git]
pull_repos = [
"project1",
"project2",
]
push_repos = [
"project1",
"project2",
]
Indeed, duplicate paths are bad :< So, what about the following approach: [git]
# Repos specified here will be pulled AND pushed
repos = []
# Repos to pull
pull_repos = []
# Repos to push
push_repos = [] For the implementation, we still only store pub struct Repositories<'a> {
git: &'a Git,
pull_repositories: HashSet<String>,
push_repositories: HashSet<String>,
glob_match_options: MatchOptions,
bad_patterns: Vec<String>,
} in if config.should_run(Step::GitRepos) {
if let Some(git_repos) = config.git_repos() {
for git_repo in git_repos {
git_repos.glob_insert_to_pull(git_repo);
git_repos.glob_insert_to_push(git_repo);
}
}
if let Some(git_pull_repos) = config.git_pull_repos() {
for git_repo in git_pull_repos {
git_repos.glob_insert_to_pull(git_repo);
}
}
if let Some(git_push_repos) = config.git_push_repos() {
for git_repo in git_push_repos {
git_repos.glob_insert_to_push(git_repo);
}
}
runner.execute(Step::GitRepos, "Git repositories", || {
git.multi_repo_step(&git_repos, &ctx)
})?;
} |
Oeh I like that, I'll make the changes! |
Should be all good now! |
Left some comments, I think this PR is ready for merge once the comments are resolved :) |
The CI failure is for the reason that #[cfg(unix)]
pub fn is_empty(&self) -> bool {
self.pull_repositories.is_empty() && self.push_repositories.is_empty()
} |
Shouldn't we also remove it for |
It seems that |
Yeah, clippy gave us a warning :<
|
my bad, added it back in! |
Removing it for |
done! |
Seems that you forgot to push your commit? |
I think we had a race condition, I pushed the commit just before you made the comment. As far as I can see it's all there now. |
I am sorry, my fault, it is indeed there, I am kinda dizzy this afternoon (my timezone) |
No worries, You've been very patient with me, so I think you deserve the same :) |
Thanks! And congratulations on your first contribution to Topgrade! |
Thank you very much, it was a pleasure ^^ |
Standards checklist
CONTRIBUTING.md
cargo build
)cargo fmt
)cargo clippy
)cargo test
)Fixes #562
Not the most elegant solution I'll admit. I'm a little sad about the duplication but I was having some real issues with the async code and opaque types when I tried to deduplicate it. This implementation works at least (at least it did for my system, don't have a setup for more robust testing) so hopefully this is good enough for a first pass. I've added config options that seemed reasonable to me. Happy reviewing!