Skip to content
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

shallow clone specific hash and export #215

Open
haudren opened this issue May 18, 2021 · 1 comment
Open

shallow clone specific hash and export #215

haudren opened this issue May 18, 2021 · 1 comment

Comments

@haudren
Copy link

haudren commented May 18, 2021

In the same line as #214 , I was playing around with shallow and noticed that importing shallowly git repositories with a version specified by a hash causes errors when exporting. Again, I am using vcstool 2.15, so there is a chance this was fixed in the later versions.

Using this YAML:

repositories:
  vcstool:
    type: git
    url: [email protected]:dirk-thomas/vcstool.git
    version: 89bbf6168680a41af2367a30c8b7e42caf81cdb9

And running

vcs import --input test.yaml --shallow --skip-existing

Followed by any of the following:

vcs export
vcs export --exact
vcs export --exact-with-tags

Results in the following error:

vcstool: Could not determine remote containing '89bbf6168680a41af2367a30c8b7e42caf81cdb9'

I have narrowed down the cause to the following line:

It seems that git rev-list --remotes=origin --tags does not return anything in this case as .git/refs is empty. I believe that a simple git rev-parse HEAD and git tag --points-at HEAD is enough information to deduce exact-with-tags, but I might be missing a lot of the details here as you seem to double check that the tag exists on the remote as well.

Note that there is an easy workaround:

vcs custom --git --args fetch --deepen 1

Will fetch a bit of history (including all tags) and that'll fix the command. There might be an even easier way, but that's what I've found so far.

Any advice on how to fix that in vcstool?

@nalt
Copy link

nalt commented Oct 25, 2024

I ran into this bug today, using https://github.com/ros2/mimick_vendor/blob/jazzy/CMakeLists.txt (which uses vcs import under the hood), followed by a manual vcs export.

As @haudren writes, it's not fully clear what the intended behavior is of rev-list and the following checks in

for remote in remotes:
# get all remote names
cmd_refs = [
GitClient._executable, 'rev-list', '--remotes=' + remote,
'--tags']
result_refs = self._run_command(cmd_refs)
if result_refs['returncode']:
result_refs['output'] = \
"Could not determine refs of remote '%s': " % \
remote + result_refs['output']
return result_refs
refs = result_refs['output'].splitlines()
if ref not in refs:
continue
It takes the named refs of the current remote plus the tags, and lists these commits and their parents. The tags might be from another remote though, so it does not really find the remote which has the current HEAD. The command returns nothing in that case as all those refs are empty.

Can anyone help with what the referenced code should do? @dirk-thomas?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants