golang/go

x/tools/go/vcs: vcs.Cmd.TagSync will fail if the repository's default branch is not 'master' [Go 1.9]

vipally opened this issue · 2 comments

  1. I use this command to clone the default branch of repository:
    git clone --depth 1 https://github.com/vipally/binary test_downloads\github.com\vipally\binary

  2. And this repository's default branch is not 'master' but 'develop'
    git status
    On branch develop
    Your branch is up-to-date with 'origin/develop'.
    nothing to commit, working tree clean

  3. After that I wanna use this code to keep working directory up-to-date with remote
    vcs.Cmd.TagSync(path, "")

    But unfortunately it will fail with report:
    error: pathspec 'master' did not match any file(s) known to git.

    Because it use such command to sync remote:
    git checkout master

    But current woring branch is not 'master' but 'develop'.

    This command is proper usage:
    git checkout

    You can see the test case here(TestDownloadAndSyncRepo):
    https://github.com/vipally/tools/blob/master/go/vcs/vcs_test.go#L158

    and fix code here:
    https://github.com/vipally/tools/blob/master/go/vcs/vcs.go#L115

    If confirm it as a bug, I will create a pullrequest to fix this issue.

I think this is cause by this https://github.com/golang/tools/blob/master/go/vcs/vcs.go#L292 that uses default command if present and a tag was not specified.

The default command https://github.com/golang/tools/blob/master/go/vcs/vcs.go#L116 uses master without invoking TagLookupCmd.

Thanks for the report. This package has been deprecated in #57051 and won't receive further development, so closing this as not planned.