vole
Clone
Read only, no credentials:
https://rodent.software/vole.git
Write over SSH with a registered key:
git clone ssh://git@rodent.software:2222/vole.git
A free and open-source forge that lives in your Git repo.
refactor
c5902451905acdaa478f8476844ccd4a510d9ca9 · Keenan Nemetz · 17d ago · parent ec2aba4b
internal/hook/releases.go → server/hook/releases.go +12−13
| @@ -11,9 +11,8 @@ import ( | |||
| 11 | 11 | "sort" | |
| 12 | 12 | "strings" | |
| 13 | 13 | ||
| 14 | "github.com/rodent-software/vole/internal/gitx" | ||
| 15 | "github.com/rodent-software/vole/internal/issues" | ||
| 16 | "github.com/rodent-software/vole/internal/releases" | ||
| 14 | "github.com/rodent-software/vole/core/git" | ||
| 15 | "github.com/rodent-software/vole/metadata" | ||
| 17 | 16 | ) | |
| 18 | 17 | ||
| 19 | 18 | // releaseFindings reports the changes that would detach a published artifact from | |
| @@ -24,14 +23,14 @@ import ( | |||
| 24 | 23 | // | |
| 25 | 24 | // Adding artifacts is allowed: an artifact is published when its pointer lands, so | |
| 26 | 25 | // there is nothing for an addition to invalidate. | |
| 27 | func releaseFindings(g *gitx.Repo, c change) []string { | ||
| 26 | func releaseFindings(g *git.Repo, c change) []string { | ||
| 28 | 27 | if strings.HasPrefix(c.ref, "refs/tags/") { | |
| 29 | 28 | name := strings.TrimPrefix(c.ref, "refs/tags/") | |
| 30 | 29 | if !tagHasArtifacts(g, name) { | |
| 31 | 30 | return nil | |
| 32 | 31 | } | |
| 33 | 32 | verb := "moved" | |
| 34 | if c.new == gitx.ZeroSHA || c.new == "" { | ||
| 33 | if c.new == git.ZeroSHA || c.new == "" { | ||
| 35 | 34 | verb = "deleted" | |
| 36 | 35 | } | |
| 37 | 36 | return []string{fmt.Sprintf( | |
| @@ -39,10 +38,10 @@ func releaseFindings(g *gitx.Repo, c change) []string { | |||
| 39 | 38 | "a release is immutable once published. Tag the new commit with a new name", | |
| 40 | 39 | c.ref, verb)} | |
| 41 | 40 | } | |
| 42 | if c.ref != issues.Ref { | ||
| 41 | if c.ref != metadata.Ref { | ||
| 43 | 42 | return nil | |
| 44 | 43 | } | |
| 45 | if c.old == "" || c.old == gitx.ZeroSHA { | ||
| 44 | if c.old == "" || c.old == git.ZeroSHA { | ||
| 46 | 45 | return nil // a new metadata branch publishes nothing old | |
| 47 | 46 | } | |
| 48 | 47 | before := releaseBlobs(g, c.old) | |
| @@ -70,8 +69,8 @@ func releaseFindings(g *gitx.Repo, c change) []string { | |||
| 70 | 69 | // releaseBlobs maps every path under releases/ in a commit to its blob id. The | |
| 71 | 70 | // blob id is the pointer text, so an unchanged artifact has an unchanged id: the | |
| 72 | 71 | // comparison needs no parsing and cannot be fooled by a reformatted pointer. | |
| 73 | func releaseBlobs(g *gitx.Repo, commit string) map[string]string { | ||
| 74 | if commit == "" || commit == gitx.ZeroSHA { | ||
| 72 | func releaseBlobs(g *git.Repo, commit string) map[string]string { | ||
| 73 | if commit == "" || commit == git.ZeroSHA { | ||
| 75 | 74 | return nil | |
| 76 | 75 | } | |
| 77 | 76 | entries, err := g.LsTreeR(commit) | |
| @@ -80,7 +79,7 @@ func releaseBlobs(g *gitx.Repo, commit string) map[string]string { | |||
| 80 | 79 | } | |
| 81 | 80 | out := map[string]string{} | |
| 82 | 81 | for _, e := range entries { | |
| 83 | if strings.HasPrefix(e.Name, releases.Dir+"/") { | ||
| 82 | if strings.HasPrefix(e.Name, metadata.ReleasesDir+"/") { | ||
| 84 | 83 | out[e.Name] = e.SHA | |
| 85 | 84 | } | |
| 86 | 85 | } | |
| @@ -91,8 +90,8 @@ func releaseBlobs(g *gitx.Repo, commit string) map[string]string { | |||
| 91 | 90 | // directory. It reads the current tip rather than the pushed tree: a tag push and | |
| 92 | 91 | // a pointer push can arrive in either order, and a tag is only bound to artifacts | |
| 93 | 92 | // that already exist. | |
| 94 | func tagHasArtifacts(g *gitx.Repo, tag string) bool { | ||
| 95 | tip, err := g.RevParse(issues.Ref) | ||
| 93 | func tagHasArtifacts(g *git.Repo, tag string) bool { | ||
| 94 | tip, err := g.RevParse(metadata.Ref) | ||
| 96 | 95 | if err != nil || tip == "" { | |
| 97 | 96 | return false | |
| 98 | 97 | } | |
| @@ -100,7 +99,7 @@ func tagHasArtifacts(g *gitx.Repo, tag string) bool { | |||
| 100 | 99 | if err != nil { | |
| 101 | 100 | return false | |
| 102 | 101 | } | |
| 103 | prefix := releases.Dir + "/" + tag + "/" | ||
| 102 | prefix := metadata.ReleasesDir + "/" + tag + "/" | ||
| 104 | 103 | for _, e := range entries { | |
| 105 | 104 | if strings.HasPrefix(e.Name, prefix) { | |
| 106 | 105 | return true | |