Skip to content

Commit

Permalink
Use --match instead of --exclude for git describe (knative#275)
Browse files Browse the repository at this point in the history
Older git versions don't have --exclude, so we match an empty tag.

Bonuses:
* ensure we have a non empty commit for tags.
* show git version on presubmit tests.
  • Loading branch information
adrcunha authored and knative-prow-robot committed Nov 22, 2018
1 parent 1aa31db commit 82b54fe
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion images/prow-tests/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# limitations under the License.

IMG = gcr.io/knative-tests/test-infra/prow-tests
TAG := $(shell date +v%Y%m%d)-$(shell git describe --always --dirty --exclude '*')
TAG := $(shell date +v%Y%m%d)-$(shell git describe --always --dirty --match '^$')

all: build

Expand Down
2 changes: 2 additions & 0 deletions scripts/presubmit-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ function main() {
kubectl version
echo ">> go version"
go version
echo ">> git version"
git version
fi

[[ -z $1 ]] && set -- "--all-tests"
Expand Down
3 changes: 2 additions & 1 deletion scripts/release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,8 @@ function parse_flags() {

if (( TAG_RELEASE )); then
# Get the commit, excluding any tags but keeping the "dirty" flag
local commit="$(git describe --always --dirty --exclude '*')"
local commit="$(git describe --always --dirty --match '^$')"
[[ -n "${commit}" ]] || abort "Error getting the current commit"
# Like kubernetes, image tag is vYYYYMMDD-commit
TAG="v$(date +%Y%m%d)-${commit}"
fi
Expand Down

0 comments on commit 82b54fe

Please sign in to comment.