Skip to content

Commit

Permalink
Add --skip flag to crosslink tidylist (#662)
Browse files Browse the repository at this point in the history
  • Loading branch information
jade-guiton-dd authored Jan 15, 2025
1 parent 74d4b2b commit c77c83e
Show file tree
Hide file tree
Showing 7 changed files with 48 additions and 0 deletions.
16 changes: 16 additions & 0 deletions .chloggen/crosslink-tidy-v2.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
change_type: 'enhancement'

# The name of the component, or a single word describing the area of concern, (e.g. crosslink)
component: crosslink

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: Added `--skip` flag to `crosslink tidylist` subcommand

# One or more tracking issues related to the change
issues: [662]

# (Optional) One or more lines of additional information to render under the primary note.
# These lines will be padded with 2 spaces and then inserted directly into the document.
# Use pipe (|) for multiline entries.
subtext:
2 changes: 2 additions & 0 deletions crosslink/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,8 @@ func init() {
comCfg.workCommand.Flags().StringVar(&comCfg.runConfig.GoVersion, "go", "1.22", "Go version applied when new go.work file is created")
comCfg.tidyListCommand.Flags().StringVar(&comCfg.runConfig.AllowCircular, "allow-circular", "", "path to list of go modules that are allowed to have circular dependencies")
comCfg.tidyListCommand.Flags().BoolVar(&comCfg.runConfig.Validate, "validate", false, "enables brute force validation of the tidy schedule")
comCfg.tidyListCommand.Flags().StringSliceVar(&comCfg.skipFlags, "skip", []string{}, "list of comma separated go.mod files that will be ignored by crosslink. "+
"multiple calls of --skip can be made")
}

// transform array slice into map
Expand Down
3 changes: 3 additions & 0 deletions crosslink/internal/mock_test_data/testTidyListOrder/gomod
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module go.opentelemetry.io/build-tools/crosslink/testroot

go 1.20
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module go.opentelemetry.io/build-tools/crosslink/testroot/testA

go 1.20

require go.opentelemetry.io/build-tools/crosslink/testroot/testC v1.0.0
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module go.opentelemetry.io/build-tools/crosslink/testroot/testB

go 1.20
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module go.opentelemetry.io/build-tools/crosslink/testroot/testC

go 1.20
16 changes: 16 additions & 0 deletions crosslink/internal/tidylist_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,22 @@ func TestTidy(t *testing.T) {
},
expSched: []string{".", "testC", "testB", "testA", "testB"},
},
{ // A -> C, B should give CAB (default to alphabetical order when no contraint)
name: "testTidyListOrder",
mock: "testTidyListOrder",
config: func(*RunConfig) {},
expSched: []string{".", "testC", "testA", "testB"},
},
{ // A -> C, B with A skipped should give BC (prune the graph, not just filter the output)
name: "testTidyListSkip",
mock: "testTidyListOrder",
config: func(config *RunConfig) {
config.SkippedPaths = map[string]struct{}{
"testA/go.mod": {},
}
},
expSched: []string{".", "testB", "testC"},
},
}
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
Expand Down

0 comments on commit c77c83e

Please sign in to comment.