-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Add --json option to fetch
#5974
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
Conversation
chrisd8088
left a comment
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 looks awesome. Thank you so much!
I've left a few comments and suggestions, but nothing major, I think. If it's easier for you, I can push a commit or two with those minor revisions and then merge the PR; just let me know what you prefer.
I should also say, thanks very much for straightening up all the --json and -j options and their documentation!
| if d.transfers != nil { | ||
| d.transfers = append(d.transfers, t) | ||
| } | ||
| if d.virtuallyFetched != nil { | ||
| d.virtuallyFetched[t.Oid] = true | ||
| } | ||
| if fetchDryRunArg { |
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.
I hemmed and hawed a bit over this, because append() will accept a nil slice and just allocate a backing array, so we could drop the make([]*tq.Transfer, 0) in the newFetchWatcher() function above, and then do something like:
if fetchJsonArg {
d.transfers = append(d.transfers, t)
}
if fetchDryRunArg {
d.virtuallyFetched[t.Oid] = true
printProgress("%s %s => %s", tr.Tr.Get("fetch"), t.Oid, t.Name)
}However, since in your next PR #5975 you're adding another flag whose state affects both functions, I think it's probably more elegant to leave it as you've written it.
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.
Fair point, I'll mull it over when I get back to that PR, maybe I can indeed move choosing the behaviour from the constructor to this function. For now, I left it like it was.
chrisd8088
left a comment
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.
Fantastic, thank you!
This adds a
--jsonoption to fetch, which is done on top of #5973.It turned out there was a minor bug in
--dry-run, where the same object was being reported fetched multiple times from different references, which diverged from non-dry-run behaviour, where the object being fetched for one ref prevented refetching for the other. This has been fixed by keeping a set of virtually fetched OIDs. This and gathering the transfers across references required sharing afetchWatcherobject acrossfetch*calls.Additionally, this PR also harmonizes the
--jsonflag occurring in different commands:-jas a shorcut (previously onlystatusdid)