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

git operation not respecting gitignore #20

Closed
tonglil opened this issue Oct 28, 2022 · 4 comments · Fixed by #25 or #27
Closed

git operation not respecting gitignore #20

tonglil opened this issue Oct 28, 2022 · 4 comments · Fixed by #25 or #27

Comments

@tonglil
Copy link

tonglil commented Oct 28, 2022

Trying to run this locally, it gets stuck because the local repository is considered dirty as it's not parsing the gitignore.

go-apidiff origin/main --repo-path=./ --print-compatible
current git tree is dirty
?? doc/.DS_Store
?? schema/.DS_Store
?? .DS_Store

It should also only consider diffing *.go files, even if other files are dirty.

Another use case is in our CI, we vendor dependencies, so it detects vendor/ as dirty.

go-git/go-git#500
go-git/go-git#387

@joelanford
Copy link
Owner

as it's not parsing the gitignore.

That's unfortunate! Let's leave this open so we can bump our go-git version when that issue is resolved.

It should also only consider diffing *.go files, even if other files are dirty.

The primary reason it bails out on a dirty tree is that it actually has to checkout the old commit, read its packages, and then re-checkout the original commit, thus leaving no trace. Perhaps there's a safe/clean way to stash the dirty tree, and then unstash it, but I was intentionally trying to be conservative to avoid messing up folks' repos.

Another use case is in our CI, we vendor dependencies, so it detects vendor/ as dirty.

The workarounds there, I think, are:

  1. Run go-apidiff prior to vendoring (or in a separate CI job).
  2. Commit the vendor directory.

@tonglil
Copy link
Author

tonglil commented Dec 19, 2022

Thanks for acknowledging Joe.

I was intentionally trying to be conservative to avoid messing up folks' repos.

I see, that makes sense! I'll have to think about how to clean the tree beforehand, perhaps git clean -fdx.

Yeah we are running it before vendoring :)

@tonglil
Copy link
Author

tonglil commented Jan 30, 2023

Running into an issue where I'm not sure how I can get the program to run locally.

The problem is that I'm not going to commit .DS_Store files, yet I can't get this tool to ignore them. When I try to delete .DS_Store files, the computer regenerates them..

@npepinpe
Copy link

npepinpe commented May 2, 2023

You could try using work trees, that would allow you to check out locally a specific commit to a temporary directory without having to clean anything.

lmb added a commit to lmb/go-apidiff that referenced this issue Jul 5, 2023
Respect patterns from ~/.gitignore or core.excludesFile if present.
This avoids the "current git tree is dirty" in some circumstances.

Fixes joelanford#20

Signed-off-by: Lorenz Bauer <lmb@isovalent.com>
lmb added a commit to lmb/go-apidiff that referenced this issue Jul 31, 2023
Respect patterns from ~/.gitignore, /etc/gitconfig or
core.excludesFile if present. This avoids the "current git
tree is dirty" in some circumstances.

Fixes joelanford#20

Signed-off-by: Lorenz Bauer <lmb@isovalent.com>
joelanford pushed a commit that referenced this issue Aug 28, 2023
Respect patterns from ~/.gitignore, /etc/gitconfig or
core.excludesFile if present. This avoids the "current git
tree is dirty" in some circumstances.

Fixes #20

Signed-off-by: Lorenz Bauer <lmb@isovalent.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants