I am trying to get the status of a file checked in a git
repo using go-git
library.
So I am running this code snippet:
var status = git.Status{}
var fileStatus *git.FileStatus
fileStatus = status.File(fullPathToApp)
fmt.Printf("%v\n", fileStatus.Staging)
fmt.Printf("%v\n", fileStatus.Worktree)
All I get is two 63
s getting printed out
63
63
What does this correspond to in terms of git status?
I cannot seem to make a direct relation to the documentation of the StatusCode
.
btw the file pointed to by fullPathToApp
is clean, i.e. it is tracked and committed.
I think you need to open the repository and worktree first
r, err := git.PlainOpen(pathToRepo)
if err != nil {
log.Fatal(err)
}
w, err := r.Worktree()
if err != nil {
log.Fatal(err)
}
After that fetch the status
ws, err := w.Status()
if err != nil {
log.Fatal(err)
}
To get the status you only need to enter the filename that is in the repository
fmt.Printf("%q\n", ws.File("filename").Staging)
fmt.Printf("%q\n", ws.File("filename").Worktree)
I cannot seem to make a direct relation to the documentation of the StatusCode.
The status code returned is a byte
63 = ?