Skip to content

Commit

Permalink
feat: switch to 8-char short-sha local identifier
Browse files Browse the repository at this point in the history
  • Loading branch information
dikderoy committed Oct 17, 2023
1 parent de99225 commit 637041e
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 13 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:

release:
needs: build
# if: github.ref == 'refs/heads/main'
if: github.ref == 'refs/heads/master'
runs-on: ubuntu-latest
permissions:
contents: write
Expand All @@ -45,6 +45,7 @@ jobs:
uses: actions/download-artifact@v3
with:
name: binaries
path: build
- name: list build artifacts
run: ls -l
- name: publish release
Expand Down
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
TagRelease
==========

[![Build Status](https://travis-ci.org/dikderoy/tagrelease.svg?branch=master)](https://travis-ci.org/dikderoy/tagrelease)
[![build](https://github.com/dikderoy/tagrelease/actions/workflows/build.yml/badge.svg)](https://github.com/dikderoy/tagrelease/actions/workflows/build.yml)
[![Maintainability](https://api.codeclimate.com/v1/badges/c0a9e573b147851c927a/maintainability)](https://codeclimate.com/github/dikderoy/tagrelease/maintainability)
[![Test Coverage](https://api.codeclimate.com/v1/badges/c0a9e573b147851c927a/test_coverage)](https://codeclimate.com/github/dikderoy/tagrelease/test_coverage)

Expand Down Expand Up @@ -56,19 +56,19 @@ select output format (default `release`):
- `release` - alias for pep440
- `pep440` - output a release string according to PEP440 format:
`{major}.{minor}.{patch}[{kind(rc|b|a)}{diff}][+{revshort}]`
example: `0.1.0+8f70f9c`, `0.8.2a84+57a182a`
example: `0.1.0+57a182a8`, `0.8.2a84+57a182a8`
- `semver` - semver release format:
`{major}.{minor}.{patch}`
example: `1.2.3`
- `short` - format: `{major}.{minor}`
example: `1.2`
- `major` - output only major version
- `minor` - output only minor version
- `patch` - output only patch version
- `major` - output only a major version
- `minor` - output only a minor version
- `patch` - output only a patch version
- `revision` - full git revision (40 chars)
example: `57a182a871e042022c22b14ad6314b0618b582f8`
- `revshort` - short git revision (7 chars)
example: `57a182a`
- `revshort` - short git revision (8 chars)
example: `57a182a8`

---

Expand Down
4 changes: 2 additions & 2 deletions tagrelease/format.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,10 @@ func (f *Formatter) Revision() string {

func (f *Formatter) RevisionShort() string {
rev := f.converter.Revision()
if len(rev) < 7 {
if len(rev) < 8 {
return rev
}
return rev[:7]
return rev[:8]
}

// PEP440 - a PEP440 compatible release identifier
Expand Down
6 changes: 3 additions & 3 deletions tagrelease/format_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,12 +127,12 @@ func TestFormatter(t *testing.T) {
pep440Expected := expected(varData,
"{{.Ver.Major}}.{{.Ver.Minor}}.{{.Ver.Patch}}"+
"{{if ne .RKind \"\" -}} {{.RKind}}{{.Ver.Diff}} {{- end -}}"+
"+57a182a")
"+57a182a5")

semverExpected := expected(varData,
"{{.Ver.Major}}.{{.Ver.Minor}}.{{.Ver.Patch}}"+
"{{if ne .RKind \"\" -}} -{{.RKind}}.{{.Ver.Diff}} {{- end -}}"+
"+57a182a")
"+57a182a5")
variants := map[string]string{
FormatRelease: pep440Expected,
FormatPEP440: pep440Expected,
Expand All @@ -142,7 +142,7 @@ func TestFormatter(t *testing.T) {
FormatMinor: expected(varData, "{{.Ver.Minor}}"),
FormatPatch: expected(varData, "{{.Ver.Patch}}"),
FormatRevision: varData.Rev,
FormatRevShort: varData.Rev[:7],
FormatRevShort: varData.Rev[:8],

"{{.Major}}+{{.Diff}}": expected(varData, "{{.Ver.Major}}+{{.Ver.Diff}}"),
}
Expand Down

0 comments on commit 637041e

Please sign in to comment.