Skip to content

Commit 8e1fe56

Browse files
committedAug 24, 2024··
Revert "feat: try to infer sub-package tag (#161)"
This reverts commit 680777b.
1 parent fc3e2dc commit 8e1fe56

File tree

2 files changed

+3
-35
lines changed

2 files changed

+3
-35
lines changed
 

‎internal/git/git.go

-6
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,6 @@ func IsRepo() bool {
2222
return err == nil && strings.TrimSpace(out) == "true"
2323
}
2424

25-
// Root returns the root of the git repository
26-
func Root() (string, error) {
27-
out, err := run("rev-parse", "--show-toplevel")
28-
return strings.TrimSpace(out), err
29-
}
30-
3125
func getAllTags(args ...string) ([]string, error) {
3226
tags, err := run(append([]string{"-c", "versionsort.suffix=-", "tag", "--sort=-version:refname"}, args...)...)
3327
if err != nil {

‎main.go

+3-29
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,9 @@ package main
33
import (
44
"fmt"
55
"os"
6-
"path"
76
"runtime/debug"
8-
"strings"
97

108
"github.com/alecthomas/kingpin/v2"
11-
"github.com/caarlos0/svu/v2/internal/git"
129
"github.com/caarlos0/svu/v2/internal/svu"
1310
)
1411

@@ -21,10 +18,10 @@ var (
2118
currentCmd = app.Command("current", "prints current version").Alias("c")
2219
preReleaseCmd = app.Command("prerelease", "new pre release version based on the next version calculated from git log").
2320
Alias("pr")
24-
preRelease = app.Flag("pre-release", "adds a pre-release suffix to the version, without the semver mandatory dash prefix").
21+
preRelease = app.Flag("pre-release", "adds a pre-release suffix to the version, without the semver mandatory dash prefix").
2522
String()
26-
pattern = app.Flag("pattern", "limits calculations to be based on tags matching the given pattern").Default(defaults("pattern")).String()
27-
prefix = app.Flag("prefix", "set a custom prefix").Default(defaults("prefix")).String()
23+
pattern = app.Flag("pattern", "limits calculations to be based on tags matching the given pattern").String()
24+
prefix = app.Flag("prefix", "set a custom prefix").Default("v").String()
2825
stripPrefix = app.Flag("strip-prefix", "strips the prefix from the tag").Default("false").Bool()
2926
build = app.Flag("build", "adds a build suffix to the version, without the semver mandatory plug prefix").
3027
String()
@@ -40,29 +37,6 @@ var (
4037
Bool()
4138
)
4239

43-
func defaults(flag string) string {
44-
var def, pat string
45-
switch flag {
46-
case "prefix":
47-
def, pat = "v", "v"
48-
case "pattern":
49-
def, pat = "", "*"
50-
default:
51-
return ""
52-
}
53-
54-
cwd, wdErr := os.Getwd()
55-
gitRoot, grErr := git.Root()
56-
if wdErr == nil && grErr == nil && cwd != gitRoot {
57-
prefix := strings.TrimPrefix(cwd, gitRoot)
58-
prefix = strings.TrimPrefix(prefix, string(os.PathSeparator))
59-
prefix = strings.TrimSuffix(prefix, string(os.PathSeparator))
60-
return path.Join(prefix, pat)
61-
}
62-
63-
return def
64-
}
65-
6640
func main() {
6741
app.Author("Carlos Alexandro Becker <carlos@becker.software>")
6842
app.Version(buildVersion(version, commit, date, builtBy))

0 commit comments

Comments
 (0)