ipbus / ipbb

IPbus Builder Tool
GNU General Public License v3.0
12 stars 12 forks source link

Fixes error when checking out git revision #203

Closed DavidMonk00 closed 7 months ago

DavidMonk00 commented 7 months ago

When checking out a specific commit, the function would fail and revert to staying at the HEAD of the master branch.

This fix should fetch, then checkout the commit.

Previous behaviour:

# ipbb add git https://gitlab.cern.ch/HPTD/tclink.git -r fda0bcf
Adding git repository https://gitlab.cern.ch/HPTD/tclink.git
Checking out revision fda0bcf
Failed to check out requested revision. Staying on default branch.
Repository 'tclink' successfully cloned to:
  /work/src/tclink
No init configuration file. Skipping.

Error raised (when raising in except block):

ipbb add git https://gitlab.cern.ch/HPTD/tclink.git -r fda0bcf
Adding git repository https://gitlab.cern.ch/HPTD/tclink.git
Checking out revision fda0bcf
Failed to check out requested revision. Staying on default branch.
ERROR: exception caught!

  RAN: /usr/bin/git fetch origin fda0bcf -q

  STDOUT:

  STDERR:
fatal: couldn't find remote ref fda0bcf
tswilliams commented 7 months ago

Hi,

Thanks for this change, however the use of revision in the git fetch was deliberate - so that the appropriate revision would always be downloaded regardless of where it is in the git history and what clone depth has been requested.

The cause of the error in the command that you quoted above is that as a side-effect of the addition of the --depth flag, the full SHA now needs to be used rather than the short SHA. On this subject, I've just updated the code (in PR #204) so that ipbb add git ... -r SHA will return a non-zero exit code if it fails to check out the specified revision; the error message also highlights if the supplied SHA is too short.

Cheers, Tom