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

This commit is contained in:
Tianon Gravi 2016-06-03 14:28:40 -07:00
parent 3538a9d438
commit 2068a11e02
3 changed files with 18 additions and 3 deletions

View File

@ -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 {

View File

@ -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

View File

@ -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]