-
Notifications
You must be signed in to change notification settings - Fork 349
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
cli: Refactor out get_fetch_remotes
into git_util.rs
#4768
base: main
Are you sure you want to change the base?
Conversation
3a16b88
to
d6df47f
Compare
e43b3b3
to
efe9c65
Compare
d6df47f
to
4a4ac40
Compare
fa6e402
to
e53870d
Compare
1591633
to
0b60444
Compare
4a4ac40
to
f4b6e5b
Compare
0b60444
to
9bde01a
Compare
f4b6e5b
to
1b5a5c0
Compare
9bde01a
to
1fc7ef9
Compare
c9ebe82
to
ae98431
Compare
c2adc4e
to
084797c
Compare
branch: args.fetch.branch.clone(), | ||
remotes: remotes.clone(), | ||
all_remotes: args.fetch.all_remotes, | ||
}, |
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.
Oh, we can't use the original args.fetch
? That makes args.fetch
useless..
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.
Maybe FetchRemoteArgs
can be extracted instead of all-in FetchArgs
, but I'm not pretty sure if that makes sense. Sorry for the noise.
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.
No worries at all, I may have jumped the gun on the Refactor before finalizing how it will be used. For sync
it turns out we need to fetch all branches for all configured remotes[1], so the help text will be different after all, and I don't need to flatten them in. I've reverted that last change, back to just passing FetchArgs{} around with branch, remotes and all_remotes as the fields.
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 not add branch
to the args struct then. It doesn't make sense to pass branch
in to get_fetch_remotes()
, and all_remotes
to git_fetch()
.
It might also be simpler to just make both get_all_remotes()
and get_default_fetch_remotes()
public.
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.
So I think I finally have something that looks descent:
git_fetch
takesFetchArgs
; which only has fields forbranch
andremotes
. This is useful since FetchArgs disambiguated the fields and makes it easier to know what goes where.get_fetch_remotes
doesn't needFetchArgs
and sinceremotes
andall_remotes
are different types completely, it doesn't look terrible if I just pass them in directly
wdyt?
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.
Seems okay.
FWIW, I wonder if git_fetch()
can actually be reused in "git sync". Suppose "git sync" does rebase based on the stats returned by git::fetch()
, "git sync" will have to use lower-level API.
Regarding args.all_remotes
, copy-pasting if args.all_remotes { ... }
block wouldn't be so bad.
5f24508
to
9b0981d
Compare
4802573
to
2e1e36b
Compare
4b26565
to
e0c7702
Compare
Similarly to `git_fetch`, this will be used in `jj git sync`, so moving this out to maintain the same behaviour across `fetch` command and `sync`. * Refactor out `get_fetch_remotes` to `git_util.rs`. * inline the different `get_*_remote*` functions into `get_fetch_remotes`; The resulting function is still small enough to be easily readable. * Move `get_single_remote` into `git_util.rs` and update call sites. * Use common FetchArgs to pass arguments both to `get_fetch_remotes` and `git_fetch` * Update use references All tests still pass. Issue: #1039
e0c7702
to
a05c655
Compare
Similarly to
git_fetch
, this will be used injj git sync
, somoving this out to maintain the same behaviour across
fetch
command andsync
.get_fetch_remotes
togit_util.rs
.get_*_remote*
functions intoget_fetch_remotes
;The resulting function is still small enough to be easily readable.
get_single_remote
intogit_util.rs
and update call sites.All tests still pass.
Issue: #1039