Repository: gembaadvantage/uplift
Pull request #13 (2021-06-25 18:57:51)

Ignore transient tags

codecov-commenter: # [Codecov](https://codecov.io/gh/gembaadvantage/uplift/pull/13?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=gembaadvantage) Report
> Merging [#13](https://codecov.io/gh/gembaadvantage/uplift/pull/13?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=gembaadvantage) (3d320f7) into [main](https://codecov.io/gh/gembaadvantage/uplift/commit/a0355d8b622e554a6dfaeb6aecf43c571bfb9bf3?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=gembaadvantage) (a0355d8) will **increase** coverage by `0.17%`.
> The diff coverage is `100.00%`.

[![Impacted file tree graph](https://codecov.io/gh/gembaadvantage/uplift/pull/13/graphs/tree.svg?width=650&height=150&src=pr&token=K13FIQH5ZB&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=gembaadvantage)](https://codecov.io/gh/gembaadvantage/uplift/pull/13?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=gembaadvantage)

```diff
@@            Coverage Diff             @@
##             main      #13      +/-   ##
==========================================
+ Coverage   81.90%   82.07%   +0.17%     
==========================================
  Files           4        4              
  Lines         210      212       +2     
==========================================
+ Hits          172      174       +2     
  Misses         27       27              
  Partials       11       11              
```


| [Impacted Files](https://codecov.io/gh/gembaadvantage/uplift/pull/13?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=gembaadvantage) | Coverage Δ | |
|---|---|---|
| [internal/git/utils.go](https://codecov.io/gh/gembaadvantage/uplift/pull/13/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=gembaadvantage#diff-aW50ZXJuYWwvZ2l0L3V0aWxzLmdv) | `67.24% <100.00%> (+1.16%)` | :arrow_up: |

------

[Continue to review full report at Codecov](https://codecov.io/gh/gembaadvantage/uplift/pull/13?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=gembaadvantage).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=gembaadvantage)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/gembaadvantage/uplift/pull/13?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=gembaadvantage). Last update [a0355d8...3d320f7](https://codecov.io/gh/gembaadvantage/uplift/pull/13?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=gembaadvantage). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=gembaadvantage).


Patch:
diff --git a/README.md b/README.md
index 7ae5555..acad1b7 100644
--- a/README.md
+++ b/README.md
@@ -77,3 +77,7 @@ bumps:
 ### $VERSION
 
 **`$VERSION`** is a placeholder and will match any semantic version, including a version with an optional `v` prefix.
+
+## Transient Tags
+
+Uplift automatically ignores any transient tag when identifying the latest version. This allows multiple tagging conventions to be safely used on your repository. A transient tag, is any tag that is not in the `1.0.0` or `v1.0.0` version format.
diff --git a/internal/git/utils.go b/internal/git/utils.go
index 9030910..29e4086 100644
--- a/internal/git/utils.go
+++ b/internal/git/utils.go
@@ -55,12 +55,18 @@ func IsRepo() bool {
 
 // LatestTag retrieves the latest tag within the repository
 func LatestTag() string {
-	tag, err := Clean(Run("describe", "--tags", "--abbrev=0"))
+	// Filter out all tags that are non in the supported formats
+	tags, err := Clean(Run("tag", "-l", "--sort=-v:refname", "v*.*.*", "*.*.*"))
 	if err != nil {
 		return ""
 	}
 
-	return tag
+	// If no tags are found, then just return an empty string
+	if tags == "" {
+		return ""
+	}
+
+	return strings.Split(tags, "\n")[0]
 }
 
 // LatestCommit retrieves the latest commit within the repository


Test patch:
diff --git a/internal/git/utils_test.go b/internal/git/utils_test.go
index 17647c8..a22f3dd 100644
--- a/internal/git/utils_test.go
+++ b/internal/git/utils_test.go
@@ -60,6 +60,18 @@ func TestLatestTagNoTagsExist(t *testing.T) {
 	assert.Equal(t, "", tag)
 }
 
+func TestLatestTagNoSemanticTags(t *testing.T) {
+	InitRepo(t)
+
+	v1 := "v1"
+	Run("tag", v1)
+	v2 := "latest"
+	EmptyCommitAndTag(t, v2, "more work")
+
+	tag := LatestTag()
+	assert.Equal(t, "", tag)
+}
+
 func TestLatestCommit(t *testing.T) {
 	InitRepo(t)