Skip to content

Commit a880f43

Browse files
committed
Add "--arch-filter" flag that mimics "--skip-constraints" but without printed warnings and without applying Constraints
1 parent 6b94cff commit a880f43

File tree

4 files changed

+29
-3
lines changed

4 files changed

+29
-3
lines changed

cmd/bashbrew/cmd-deps.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ func cmdFamily(parents bool, c *cli.Context) error {
3232

3333
uniq := c.Bool("uniq")
3434
applyConstraints := c.Bool("apply-constraints")
35+
archFilter := c.Bool("arch-filter")
3536
depth := c.Int("depth")
3637

3738
allRepos, err := repos(true)
@@ -53,6 +54,9 @@ func cmdFamily(parents bool, c *cli.Context) error {
5354
if applyConstraints && r.SkipConstraints(entry) {
5455
continue
5556
}
57+
if archFilter && !entry.HasArchitecture(arch) {
58+
continue
59+
}
5660

5761
for _, tag := range r.Tags(namespace, false, entry) {
5862
network.AddNode(tag, entry)
@@ -70,9 +74,12 @@ func cmdFamily(parents bool, c *cli.Context) error {
7074
if applyConstraints && r.SkipConstraints(entry) {
7175
continue
7276
}
77+
if archFilter && !entry.HasArchitecture(arch) {
78+
continue
79+
}
7380

7481
entryArches := []string{arch}
75-
if !applyConstraints {
82+
if !applyConstraints && !archFilter {
7683
entryArches = entry.Architectures
7784
}
7885

@@ -102,6 +109,9 @@ func cmdFamily(parents bool, c *cli.Context) error {
102109
if applyConstraints && r.SkipConstraints(entry) {
103110
continue
104111
}
112+
if archFilter && !entry.HasArchitecture(arch) {
113+
continue
114+
}
105115

106116
// we can't include SharedTags here or else they'll make "bashbrew parents something:simple" show the parents of the shared tags too ("nats:scratch" leading to both "nats:alpine" *and* "nats:windowsservercore" instead of just "nats:alpine" like it should), so we have to reimplement bits of "r.Tags" to exclude them
107117
tagRepo := path.Join(namespace, r.RepoName)

cmd/bashbrew/cmd-from.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ func cmdFrom(c *cli.Context) error {
1515

1616
uniq := c.Bool("uniq")
1717
applyConstraints := c.Bool("apply-constraints")
18+
archFilter := c.Bool("arch-filter")
1819

1920
for _, repo := range repos {
2021
r, err := fetch(repo)
@@ -26,9 +27,12 @@ func cmdFrom(c *cli.Context) error {
2627
if applyConstraints && r.SkipConstraints(entry) {
2728
continue
2829
}
30+
if archFilter && !entry.HasArchitecture(arch) {
31+
continue
32+
}
2933

3034
entryArches := []string{arch}
31-
if !applyConstraints {
35+
if !applyConstraints && !archFilter {
3236
entryArches = entry.Architectures
3337
}
3438

cmd/bashbrew/cmd-list.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ func cmdList(c *cli.Context) error {
1616

1717
uniq := c.Bool("uniq")
1818
applyConstraints := c.Bool("apply-constraints")
19+
archFilter := c.Bool("arch-filter")
1920
onlyRepos := c.Bool("repos")
2021

2122
buildOrder := c.Bool("build-order")
@@ -57,6 +58,9 @@ func cmdList(c *cli.Context) error {
5758
if applyConstraints && r.SkipConstraints(entry) {
5859
continue
5960
}
61+
if archFilter && !entry.HasArchitecture(arch) {
62+
continue
63+
}
6064

6165
for _, tag := range r.Tags(namespace, uniq, entry) {
6266
fmt.Printf("%s\n", tag)

cmd/bashbrew/main.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,11 @@ func main() {
210210
},
211211
"apply-constraints": cli.BoolFlag{
212212
Name: "apply-constraints",
213-
Usage: "apply Constraints as if repos were building",
213+
Usage: "apply all Constraints (including Architectures) as if repos were building",
214+
},
215+
"arch-filter": cli.BoolFlag{
216+
Name: "arch-filter",
217+
Usage: "like apply-constraints, but only for Architectures",
214218
},
215219
"depth": cli.IntFlag{
216220
Name: "depth",
@@ -240,6 +244,7 @@ func main() {
240244
commonFlags["all"],
241245
commonFlags["uniq"],
242246
commonFlags["apply-constraints"],
247+
commonFlags["arch-filter"],
243248
cli.BoolFlag{
244249
Name: "build-order",
245250
Usage: "sort by the order repos would need to build (topsort)",
@@ -321,6 +326,7 @@ func main() {
321326
Usage: `print the repos built FROM a given repo or repo:tag`,
322327
Flags: []cli.Flag{
323328
commonFlags["apply-constraints"],
329+
commonFlags["arch-filter"],
324330
commonFlags["depth"],
325331
commonFlags["uniq"],
326332
},
@@ -338,6 +344,7 @@ func main() {
338344
Usage: `print the repos this repo or repo:tag is FROM`,
339345
Flags: []cli.Flag{
340346
commonFlags["apply-constraints"],
347+
commonFlags["arch-filter"],
341348
commonFlags["depth"],
342349
commonFlags["uniq"],
343350
},
@@ -375,6 +382,7 @@ func main() {
375382
commonFlags["all"],
376383
commonFlags["uniq"],
377384
commonFlags["apply-constraints"],
385+
commonFlags["arch-filter"],
378386
},
379387
Before: subcommandBeforeFactory("from"),
380388
Action: cmdFrom,

0 commit comments

Comments
 (0)