-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
--new/--new-from-rev flags does not work #948
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
Comments
Some additional findings:
Perhaps that could be reported to https://github.com/bradleyfalzon/revgrep, but it seems unmaintained and https://github.com/golangci/revgrep does not have issue tracking enabled... Edit: so it seems there are 2 issues here:
|
I guess following patch will ensure, that prefixes are always there: diff --git a/revgrep.go b/revgrep.go
index 3650d64..d9b9942 100644
--- a/revgrep.go
+++ b/revgrep.go
@@ -356,7 +356,7 @@ func GitPatch(revisionFrom, revisionTo string) (io.Reader, []string, error) {
}
if revisionFrom != "" {
- cmd := exec.Command("git", "diff", "--relative", revisionFrom)
+ cmd := exec.Command("git", "diff", "-src-prefix=a/", "--dst-prefix=b/", "--relative", revisionFrom)
if revisionTo != "" {
cmd.Args = append(cmd.Args, revisionTo)
}
@@ -373,7 +373,7 @@ func GitPatch(revisionFrom, revisionTo string) (io.Reader, []string, error) {
// make a patch for unstaged changes
// use --no-prefix to remove b/ given: +++ b/main.go
- cmd := exec.Command("git", "diff", "--relative")
+ cmd := exec.Command("git", "diff", "--src-prefix=a/", "--dst-prefix=b/", "--relative")
cmd.Stdout = &patch
if err := cmd.Run(); err != nil {
return nil, nil, fmt.Errorf("error executing git diff: %s", err)
@@ -388,7 +388,7 @@ func GitPatch(revisionFrom, revisionTo string) (io.Reader, []string, error) {
// check for changes in recent commit
- cmd = exec.Command("git", "diff", "--relative", "HEAD~")
+ cmd = exec.Command("git", "diff", "--src-prefix=a/", "--dst-prefix=b/", "--relative", "HEAD~")
cmd.Stdout = &patch
if err := cmd.Run(); err != nil {
return nil, nil, fmt.Errorf("error executing git diff HEAD~: %s", err) |
This comment has been minimized.
This comment has been minimized.
I'm also seeing some issues with the
Edit to add: rolling back from v1.23.6 to v.1.23.3 seems to have helped; I'm now seeing issues that were introduced only since the nominated revision come up once again. |
It's unreliable[1], and golangci-lint can produce false positives with this approach, though it might be a bug[2]. This --first-parent also might not work for all cases, though... [1]: https://discuss.circleci.com/t/circle-compare-url-is-empty/ [2]: golangci/golangci-lint#948 (comment)
It's unreliable[1], and golangci-lint can produce false positives with this approach, though it might be a bug[2]. This --first-parent also might not work for all cases, though... [1]: https://discuss.circleci.com/t/circle-compare-url-is-empty/ [2]: golangci/golangci-lint#948 (comment)
It's unreliable[1], and golangci-lint can produce false positives with this approach, though it might be a bug[2]. This --first-parent also might not work for all cases, though... [1]: https://discuss.circleci.com/t/circle-compare-url-is-empty/ [2]: golangci/golangci-lint#948 (comment)
This comment has been minimized.
This comment has been minimized.
After running the linter, restore local settings to original variable or just unset it. This is to avoid people hitting golangci/golangci-lint#948, as it seems the note in Makefile is not good enough. Signed-off-by: Mateusz Gozdek <[email protected]>
After running the linter, restore local settings to original variable or just unset it. This is to avoid people hitting golangci/golangci-lint#948, as it seems the note in Makefile is not good enough. Signed-off-by: Mateusz Gozdek <[email protected]>
This comment has been minimized.
This comment has been minimized.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
It seems that
--new
or/and--new-from-rev
flags are not really working. I've created test repository to demonstrate: https://github.com/invidian/golangci-lint-new-from-revThere are 2 branches,
master
with one issue andnew
with 2 issues. When running following command onnew
branch:I would expect to just see one warning introduced in commit 0a550855f7a5573e791060cb1f3ab1e6a5eacbee. However, I see none. The same thing happens, when I introduce new code, which should result in warning and I run the linter with
--new
.When running without
--new
and/or--new-from-rev
, everything seems fine. My guess is, that https://github.com/golangci/revgrep is just filtering all found issues, instead of just old ones. I've tried testing the following:But it gives the same result (no warnings printed). And the debug output:
Thank you for creating the issue!
Please include the following information:
Version of golangci-lint
Config file
Go environment
Verbose output of running
The text was updated successfully, but these errors were encountered: