captain icon indicating copy to clipboard operation
captain copied to clipboard

Captain push -Bc fails when on a tag

Open jwliechty opened this issue 6 years ago • 0 comments

If on a tag of a git repository (for instance v3.0 and doing a captain push -Bc, there is an error where captain tries to create a docker tag with the name (HEAD detached at v3.0). This is because the getBranches function uses the following command to get all the branch names.

git branch --no-column --contains HEAD

Which gives the output (on my system)

* (HEAD detached at v3.0)
  b-four
  b-one
  b-three
  b-two
  master

The other interesting thing is that it uses the --contains flag. Instead, I think this should be the --points-at. If pushing up docker contains for tagged with branches, wouldn't you want to do so only for those branches whose HEAD is the same as what you currently have checked out? As it stands, the --contains will grab any branch that has the HEAD commit. This means that if on master and pushing with -B, master and develop will get tagged and pushed up even if develop is ahead of master in commits.

I have a pull request which addresses both of these concerns with tests!

Please review and accept!

jwliechty avatar May 17 '19 21:05 jwliechty