feat: list files by git when possible#133
Conversation
Signed-off-by: tison <[email protected]>
Signed-off-by: tison <[email protected]>
Signed-off-by: tison <[email protected]>
Signed-off-by: tison <[email protected]>
Signed-off-by: tison <[email protected]>
Signed-off-by: tison <[email protected]>
Signed-off-by: tison <[email protected]>
Signed-off-by: tison <[email protected]>
Signed-off-by: tison <[email protected]>
Signed-off-by: tison <[email protected]>
Signed-off-by: tison <[email protected]>
Signed-off-by: tison <[email protected]>
Signed-off-by: tison <[email protected]>
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 <[email protected]>
Signed-off-by: tison <[email protected]>
|
@kezhenxu94 fixed at 18af4c4. |
kezhenxu94
left a comment
There was a problem hiding this comment.
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 1In 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 <[email protected]>
|
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 <[email protected]>
|
@kezhenxu94 it's a There're still some issues about |
Signed-off-by: tison <[email protected]>
I spot that it's about another issue on the master branch. I'll create an issue for it. UPDATE - apache/skywalking#9560 |
kezhenxu94
left a comment
There was a problem hiding this comment.
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
~/.gitignoreAlso left some minor comment, the PR is good enough for me.
Signed-off-by: tison <[email protected]>
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
.gitignorefile, 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: