Closed michael-o closed 3 years ago
I just rewrote get_commit_details to use the v2 protocol syntax and I believe I've fixed the issue here. How do things look on your end? Thank you!
Not quite:
root@bsd1srv:~/gitup (main %=)
# /gitup stable -t release/12.2.0
# Host: github.com
# Port: 443
# Repository: /freebsd/freebsd.git
# Target: /usr/src
# Tag: release/12.2.0
# Have: 1d21fe9cea3f530b4cfca495632d5a1595a32270
# Want: 1d21fe9cea3f530b4cfca495632d5a1595a32270
# Branch: stable/12
root@bsd1srv:~/gitup (main %=)
# /gitup stable -w 1d21fe9cea3f530b4cfca495632d5a1595a32270
# Host: github.com
# Port: 443
# Repository: /freebsd/freebsd.git
# Target: /usr/src
# Have: 1d21fe9cea3f530b4cfca495632d5a1595a32270
# Want: 1d21fe9cea3f530b4cfca495632d5a1595a32270
# Branch: (detached)
Branch and Tag are mutually exclusive, you are printing both. This is the cause: https://github.com/johnmehr/gitup/blob/2d3daf03549374b31c40a068c3e8a9ab71f426f9/gitup.c#L1230-L1236
but you also have this:
https://github.com/johnmehr/gitup/blob/2d3daf03549374b31c40a068c3e8a9ab71f426f9/gitup.c#L2313-L2320
This is inconsistent. Branch, Tag, and Want are again mutually exclusive. The branch from the config file is a fallback (default) when nothing explicit has been provided.
If I'm following you correctly, I think this is related to Issue #20 -- when a want is specified, there's no way to determine the branch it belongs to. As long as the want can be found in the repository, the git server will silently provide the pack file needed to convert the have to the want even if it jumps branches.
I just did a test to double-check this by running gitup current -w 4493b69d4aa4fd18d5a6d71b058a2efb74d43421
(4493b69d4 is the most recent commit to stable/12) and it converted my current tree to stable/12 and there's no way to know (that I've been able to determine) that the local copy of current is not on the main branch anymore.
While this behavior can be problematic for the source trees, it makes automatically tracking the current quarterly ports branch super easy so I'm not sure what can be done apart from printing some warning text when a want is specified and updating the man pages to warn people.
Thoughts?
Apoligies not being clear enough, the behavior is just fine, no issues here, but it is solely the verbose output which does not match the written content to disk.
Expectations:
(detached)
.It is actually about consistent output and the fact that one should not be able to do this:
$ gitup stable -w abd... -t release/...
which makes no sense that's what the code spots point to.
This is how the ouput should look like:
root@bsd1srv:~/gitup (main %=)
# /gitup stable -t release/12.2.0
# Host: github.com
# Port: 443
# Repository: /freebsd/freebsd.git
# Target: /usr/src
# Tag: release/12.2.0
# Have: 1d21fe9cea3f530b4cfca495632d5a1595a32270
# Want: 1d21fe9cea3f530b4cfca495632d5a1595a32270
root@bsd1srv:~/gitup (main %=)
# /gitup stable -w 1d21fe9cea3f530b4cfca495632d5a1595a32270
# Host: github.com
# Port: 443
# Repository: /freebsd/freebsd.git
# Target: /usr/src
# Have: 1d21fe9cea3f530b4cfca495632d5a1595a32270
# Want: 1d21fe9cea3f530b4cfca495632d5a1595a32270
# Branch: (detached)
* Have:
can only appear when /var/db/gitup
contains a section reference, of course.
Is that better now?
Yes. I just pushed out an update that should now display the three cases correctly as well as dropping the want and using the tag whenever both a tag and a want are specified on the command line. Thank you!
Checking...
This looks good now, but I would recommend the following improvement since you have opted to drop want
if tag
is supplied:
std
that both have been supplied and you use tag only,Exiting when both a tag and a want is a much better solution and I just push an update. Thank you!
Looks good!
This is actual a two-fold issue, one regarding the
# Branch:
output and the code itself. I will split it.Output: Since tags are now properly handled the output says:
# Branch: refs/tags/...
. This is wrong in two ways: (1) it is not a branch, (2) this is not a tag. The actual output is a reference. Code: The variablefull_branch
unfortunately conflates many things: (1) a reference, (2) parse arg for thePOST
response (3) formatting for output.Options to solve Output:
Branch
toRef
and this is consistentOptions to solve Code: Introduce variable
full_ref
which hold the full ref, and nothing else but the ref:refs/tags/release/12.2.0
orrefs/heads/stable/12
. If the parse arg of thePOST
request requires more information usefull_ref
to construct the arg withsprintf()
and frieds. Formatting output shall either rely onfull_ref
only or on branch, want, or tag depending on the input. The variablefull_branch
will go way.