diff --git a/go/src/bashbrew/cmd-build.go b/go/src/bashbrew/cmd-build.go index ec4012a..c5158e0 100644 --- a/go/src/bashbrew/cmd-build.go +++ b/go/src/bashbrew/cmd-build.go @@ -45,7 +45,7 @@ func cmdBuild(c *cli.Context) error { if pullMissing && from != "scratch" { _, err := dockerInspect("{{.Id}}", from) if err != nil { - fmt.Printf("Pulling %s (%s)\n", from, r.RepoName) + fmt.Printf("Pulling %s (%s)\n", from, r.Identifier()) dockerPull(from) } } @@ -60,7 +60,7 @@ func cmdBuild(c *cli.Context) error { // check whether we've already built this artifact _, err = dockerInspect("{{.Id}}", cacheTag) if err != nil { - fmt.Printf("Building %s (%s)\n", cacheTag, r.RepoName) + fmt.Printf("Building %s (%s)\n", cacheTag, r.Identifier()) commit, err := r.fetchGitRepo(&entry) if err != nil { diff --git a/go/src/bashbrew/main.go b/go/src/bashbrew/main.go index 87bb785..620dbcf 100644 --- a/go/src/bashbrew/main.go +++ b/go/src/bashbrew/main.go @@ -83,6 +83,7 @@ func sortRepos(repos []string) ([]string, error) { return nil, err } rs = append(rs, r) + network.AddNode(r.Identifier(), repo) network.AddNode(r.RepoName, repo) } @@ -101,6 +102,7 @@ func sortRepos(repos []string) ([]string, error) { continue } // TODO somehow reconcile/avoid "a:a -> b:b, b:b -> a:c" (which will exhibit here as cyclic) + network.AddEdgeIfExists(from, r.Identifier()) network.AddEdgeIfExists(from, r.RepoName) } } @@ -111,8 +113,14 @@ func sortRepos(repos []string) ([]string, error) { } ret := []string{} + seen := map[string]bool{} for _, node := range nodes { - ret = append(ret, node.Value.(string)) + repo := node.Value.(string) + if seen[repo] { + continue + } + seen[repo] = true + ret = append(ret, repo) } return ret, nil diff --git a/go/src/bashbrew/repo.go b/go/src/bashbrew/repo.go index 581ed0b..0a0ee11 100644 --- a/go/src/bashbrew/repo.go +++ b/go/src/bashbrew/repo.go @@ -24,6 +24,13 @@ type Repo struct { TagEntry *manifest.Manifest2822Entry } +func (r Repo) Identifier() string { + if r.TagName != "" { + return r.RepoName + ":" + r.TagName + } + return r.RepoName +} + func (r Repo) SkipConstraints(entry manifest.Manifest2822Entry) bool { repoTag := r.RepoName + ":" + entry.Tags[0]