Closed jwliechty closed 5 years ago
Tested and it works properly.
Here is a quick way to test it locally (a variation of the test defined at #63)
git init
cat > Dockerfile << EOL
FROM scratch
EXPOSE 80
EOL
git add Dockerfile
git commit -am 'Testing'
git tag -a 1.0.0 -m 'test tag'
captain build
Another PR that addresses #63.
Doing a
captain build
when on a tagged commit currently causes a erroneous tag name. For example, if on a tag v1.0 of a repository, when the captain build occurs, this this the output:Notice the
tags.v1.0^0
. That is wrong on two fronts. 1.) the tag should bev1.0
and 2.) the carrot symbol^
makes it an invalid format for a docker tag.The problem occurs when obtaining the branch names. The code uses the command
git name-rev --name-only HEAD
to determine the branch name. This used to work. However, git must have changed over the years because if you are on a tag, this now returnstags.v1.0^0
.Fortunately, the same command has an
--exclude
parameter that will allow us to indicate to filter out tags (which is what we wanted anyway for that particular call). The tags are determined later via the git commandgit tag --points-at HEAD
. (all of these references occur ingit.go
)When running tests, as they currently are, they failed for this very reason. After excluding tags with the
--exclude
parameter to the git command, all the tests pass. (I am running git version 2.17.1 on Ubuntu 18.04)Please accept this PR and create a new distributable so I and others do not run into this again.