diff options
| author | Jeff Carr <[email protected]> | 2024-01-11 23:24:09 -0600 |
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2024-01-11 23:24:09 -0600 |
| commit | e2acf6511eb908cbc7813b8bda925c065e0b673a (patch) | |
| tree | 559750c7fef0a49887f3b0c0064874a0ba5b4e57 /git.go | |
| parent | 1248e21394afa41f5a5a42e843c3bd4cae71c5d6 (diff) | |
skip HEAD
Signed-off-by: Jeff Carr <[email protected]>
Diffstat (limited to 'git.go')
| -rw-r--r-- | git.go | 50 |
1 files changed, 50 insertions, 0 deletions
@@ -1,6 +1,10 @@ package repostatus import ( + "strings" + "unicode/utf8" + + "io/ioutil" "go.wit.com/log" ) @@ -110,3 +114,49 @@ func (rs *RepoStatus) checkoutBranch(level string, branch string) { default: } } + +func (rs *RepoStatus) checkBranches() bool { + var hashCheck string + var perfect bool = true + all := rs.getBranches() + path := fullpath(rs.repopath + "/.git/refs/") + for _, b := range all { + parts := strings.Split(b, "/") + rdir := "heads" + if len(parts) == 2 { + rdir = "remotes" + } + fullfile := path + "/" + rdir + "/" + b + + // check if the ref name is "HEAD". if so, skip + runeCount := utf8.RuneCountInString(fullfile) + // Convert the string to a slice of runes + runes := []rune(fullfile) + // Slice the last 4 runes + lastFour := runes[runeCount-4:] + if string(lastFour) == "HEAD" { + log.Warn("skip HEAD fullfile", fullfile) + continue + } + + content, _ := ioutil.ReadFile(fullfile) + hash := strings.TrimSpace(string(content)) + if hashCheck == "" { + hashCheck = hash + } + var cmd []string + cmd = append(cmd, "git", "show", "-s", "--format=%ci", hash) + _, _, output := runCmd(rs.repopath, cmd) + // git show -s --format=%ci <hash> will give you the time + // log.Warn(fullfile) + if hash == hashCheck { + log.Warn(hash, output, b) + } else { + log.Warn(hash, output, b, "NOT THE SAME") + perfect = false + parts := strings.Split(b, "/") + log.Warn("git push", parts) + } + } + return perfect +} |
