问题
I am trying to check the status of a particular file in a git
repo using go-git
library.
This is the code I am attempting to run:
repo, err := git.PlainOpen(fullPathToRepo)
if err != nil {
return false, fmt.Errorf("ERROR: Unable to open repository %s\n%s", fullPathToRepo, err)
}
workTree, err := repo.Worktree()
if err != nil {
return false, fmt.Errorf("ERROR: Unable to open worktree for repository %s\n%s", fullPathToRepo, err)
}
workTreeStatus, err := workTree.Status()
if err != nil {
return false, fmt.Errorf("ERROR: Unable to retrieve worktree status for repository %s\n%s", fullPathToRepo, err)
}
fmt.Printf("%q\n", workTreeStatus.File("releases/filename").Worktree)
fmt.Printf("%q\n", workTreeStatus.File("/Users/panteliskaramolegkos/myrepo/filename/releases/faros.yaml").Worktree)
return workTreeStatus.IsClean(), nil
i.e. I am attempting to use both the full as also the relevant (to the repo) path to the file I want to check.
In both cases what is printed out is the following:
`?`
`?`
According to the documentation however, this corresponds to an Untracked
file.
The specific file is properly committed and checked in.
Why am I getting the wrong status code?
来源:https://stackoverflow.com/questions/62738651/go-git-reports-a-file-as-untracked-while-it-should-be-unmodified