work on supporting arbitrary paths

This commit is contained in:
Jeff Carr 2024-12-16 03:04:39 -06:00
parent cea5968b0f
commit a115ba144b
Notes: Jeff Carr 2024-12-16 04:06:57 -06:00
// `autogen:go.mod`

module go.wit.com/lib/protobuf/gitpb

go 1.21

toolchain go1.23.4

require (
	github.com/destel/rill v0.6.0
	github.com/go-cmd/cmd v1.4.3
	go.wit.com/lib/gui/shell v0.22.17
	go.wit.com/log v0.22.9
	google.golang.org/protobuf v1.35.2
)

// `autogen:go.sum`

github.com/destel/rill v0.6.0 h1:8MQRzS6k0akKmwNZFahKIhG1dkBeNxMoWKSfOxkaJNw=
github.com/destel/rill v0.6.0/go.mod h1:srKuXzvGqINUEGYR5b/iwvW+L9/S35RxVHWGYbXNoO4=
github.com/go-cmd/cmd v1.4.3 h1:6y3G+3UqPerXvPcXvj+5QNPHT02BUw7p6PsqRxLNA7Y=
github.com/go-cmd/cmd v1.4.3/go.mod h1:u3hxg/ry+D5kwh8WvUkHLAMe2zQCaXd00t35WfQaOFk=
github.com/go-test/deep v1.1.0 h1:WOcxcdHcvdgThNXjw0t76K42FXTU7HpNQWHpA2HHNlg=
github.com/go-test/deep v1.1.0/go.mod h1:5C2ZWiW0ErCdrYzpqxLbTX7MG14M9iiw8DgHncVwcsE=
github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU=
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
go.wit.com/lib/gui/shell v0.22.17 h1:JfGozzkhrlCDCtQCVgVExobvseFc2ZIM9r76cXCouwg=
go.wit.com/lib/gui/shell v0.22.17/go.mod h1:zduuMSWq+EE7w0xbXn+vkoGZ4HJhURVJpvXw8oK9WAU=
go.wit.com/log v0.22.9 h1:aBM6SI2kxlJcBfS/osFTomJqNhO0hfEo1gk+LCqLk7Y=
go.wit.com/log v0.22.9/go.mod h1:4uNPFBqhsAh8zNF+zxVEmC3c/9AZ8JeTfUUvRpddvLQ=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
google.golang.org/protobuf v1.35.2 h1:8Ar7bF+apOIoThw1EdZl0p1oWvMqTHmpA2fRTyZO8io=
google.golang.org/protobuf v1.35.2/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE=

// `autogen:`
2 changed files with 20 additions and 1 deletions

View File

@ -77,6 +77,7 @@ func (repo *Repo) GetUserVersion() string {
return ""
}
}
func (repo *Repo) GetCurrentBranchName() string {
r := repo.RunQuiet([]string{"git", "branch", "--show-current"})
output := strings.Join(r.Stdout, "\n")
@ -87,6 +88,24 @@ func (repo *Repo) GetCurrentBranchName() string {
return strings.TrimSpace(output)
}
// this is used often. probably move everything to this
// returns things like
// v0.2.2
// v0.22.39-1-g2141737
// v0.23-dirty
// mystuff
func (repo *Repo) GetCurrentVersion() string {
if repo == nil {
return ""
}
bver := repo.GetCurrentBranchVersion()
if repo.CheckDirty() {
bver = bver + "-dirty"
}
return bver
}
// always spawns 'git' and always should spawn 'git'
func (repo *Repo) GetCurrentBranchVersion() string {
if repo == nil {
log.Info("repo.GetCurrentBranchVersion() repo == nil")

View File

@ -12,7 +12,7 @@ import "google/protobuf/timestamp.proto"; // Import the well-known type for Time
// global settings for autogenpb `autogenpb:mutex`
message Repo { // `autogenpb:marshal`
string fullPath = 1; // the actual path to the .git directory: '/home/devel/golang.org/x/tools'
string fullPath = 1; // `autogenpb:unique` // the actual path to the .git directory: '/home/devel/golang.org/x/tools'
google.protobuf.Timestamp lastPull = 2; // last time a git pull was done
string masterBranchName = 3; // git 'main' or 'master' branch name
string develBranchName = 4; // whatever the git 'devel' branch name is