-
Notifications
You must be signed in to change notification settings - Fork 57
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
feat: list files by git when possible #133
Conversation
Signed-off-by: tison <wander4096@gmail.com>
Signed-off-by: tison <wander4096@gmail.com>
Signed-off-by: tison <wander4096@gmail.com>
Signed-off-by: tison <wander4096@gmail.com>
Signed-off-by: tison <wander4096@gmail.com>
Signed-off-by: tison <wander4096@gmail.com>
Signed-off-by: tison <wander4096@gmail.com>
Signed-off-by: tison <wander4096@gmail.com>
This is a good idea, but it looks like the implementation in this PR only lists files that have been committed into the codebase, however, in most cases, I'm using the tool in the following workflow:
In this PR, nothing will be fixed, even if I run This also breaks users who used this tool as a git pre-commit hook. |
@kezhenxu94 good point. Let me try to find a way to list staged/unstaged files. |
Signed-off-by: tison <wander4096@gmail.com>
Signed-off-by: tison <wander4096@gmail.com>
@kezhenxu94 fixed at 18af4c4. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Basically looks good to me, except that it doesn't resolve the problem as the PR description claimed, it's possible that users have a global git ignore settings.
, the files contained in global .gitignore
are still checked.
Reproduce:
skywalking-eyes pr/tisonkun/133 % g
On branch pr/tisonkun/133
Your branch is up to date with 'tisonkun/list-files-by-git'.
nothing to commit, working tree clean
skywalking-eyes pr/tisonkun/133 % g config --global core.excludesFile
~/.gitignore
skywalking-eyes pr/tisonkun/133 % tail -n1 ~/.gitignore
.tool-versions
skywalking-eyes pr/tisonkun/133 % touch .tool-versions
skywalking-eyes pr/tisonkun/133 % go run cmd/license-eye/main.go h c
INFO Loading configuration from file: .licenserc.yaml
INFO Totally checked 726 files, valid: 59, invalid: 1, ignored: 666, fixed: 0
ERROR the following files don't have a valid license header:
.tool-versions
ERROR one or more files does not have a valid license header
exit status 1
In terms of this case, it is neither better or worse than before so I'm OK if you want to stop at this point or continue to resolve that case. @tisonkun
Co-authored-by: kezhenxu94 <kezhenxu94@apache.org>
This patch fixes my case under
... where:
I'll try to dig it out a bit :) |
@kezhenxu94 I think we can handle the returned |
Signed-off-by: tison <wander4096@gmail.com>
@kezhenxu94 it's a There're still some issues about |
Signed-off-by: tison <wander4096@gmail.com>
I spot that it's about another issue on the master branch. I'll create an issue for it. UPDATE - apache/skywalking#9560 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is still a culprit in the go-git upstream, it doesn't expand the tilde (~
) for the core.excludesfile
, which I think it should, so this still doesn't solve my problem.
skywalking-eyes pr/tisonkun/133 % g config --global core.excludesfile
~/.gitignore
Also left some minor comment, the PR is good enough for me.
Signed-off-by: tison <wander4096@gmail.com>
I dug the code a bit. Finally, I notice that it's the Golang stdlib that causes the issue: func main() {
_, err := os.OpenFile("~/.gitignore", 0, 0666)
fmt.Printf("%v", err)
}
// open ~/.gitignore: no such file or directory |
Set up a cross-reference to go-git/go-git#578. If upstream resolves this issue, we can upgrade to fix the |
Although we try to use ignore pattern present by a
.gitignore
file, it's possible that users have a global git ignore settings or manually ignore a file.We can use git command to list files when runs under a git worksapce, and if there's no git workspace, we don't have to see
.gitignore
. Normally, it's via directly download and all ignored files already excluded. If users want to respect to the ignore pattern, they can simplygit init
.cc @kezhenxu94 @wu-sheng @fgksgf @spacewander
Reference: