ソースを参照

Fix "bashbrew list --uniq --build-order alpine:latest alpine:3.3" (to properly list two tags instead of just one)

Tianon Gravi 9 年 前
コミット
66ff2924c2

+ 2 - 2
bashbrew/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 {

+ 9 - 1
bashbrew/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

+ 7 - 0
bashbrew/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]