Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(changefinder): add -base flag #7889

Merged
merged 1 commit into from
May 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions internal/actions/cmd/changefinder/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ The available flags are as follows:
* `-format=[plain|github]`: The `stdout` output format. Default is `plain`.
* `-gh-var=[variable name]`: The variabe name to set output for in `github`
format mode. Defaults to `submodules`.
* `-base=[ref name]`: The base ref to compare `HEAD` to. Default is
`origin/main`.

Example usages from this repo root:

Expand Down
3 changes: 2 additions & 1 deletion internal/actions/cmd/changefinder/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ var (
dir = flag.String("dir", "", "the root directory to evaluate")
format = flag.String("format", "plain", "output format, one of [plain|github], defaults to 'plain'")
ghVarName = flag.String("gh-var", "submodules", "github format's variable name to set output for, defaults to 'submodules'.")
base = flag.String("base", "origin/main", "the base ref to compare to, defaults to 'origin/main'")
quiet = flag.Bool("q", false, "quiet mode, minimal logging")
// Only used in quiet mode, printed in the event of an error.
logBuffer []string
Expand Down Expand Up @@ -127,7 +128,7 @@ func mods(dir string) (submodules []string, err error) {
}

func gitFilesChanges(dir string) ([]string, error) {
c := exec.Command("git", "diff", "--name-only", "origin/main")
c := exec.Command("git", "diff", "--name-only", *base)
c.Dir = dir
b, err := c.Output()
if err != nil {
Expand Down