Refactor code to live inside default pkg
This commit is contained in:
parent
9060b44e6d
commit
22a5d2abf8
8 changed files with 589 additions and 268 deletions
14
git/git.go
14
git/git.go
|
|
@ -394,7 +394,6 @@ func ToplevelDir() (string, error) {
|
|||
}
|
||||
output, err := run.PrepareCmd(showCmd).Output()
|
||||
return firstLine(output), err
|
||||
|
||||
}
|
||||
|
||||
// ToplevelDirFromPath returns the top-level given path of the current repository
|
||||
|
|
@ -439,3 +438,16 @@ func getBranchShortName(output []byte) string {
|
|||
branch := firstLine(output)
|
||||
return strings.TrimPrefix(branch, "refs/heads/")
|
||||
}
|
||||
|
||||
func IsGitDirectory() bool {
|
||||
showCmd, err := GitCommand("rev-parse", "--is-inside-work-tree")
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
output, err := run.PrepareCmd(showCmd).Output()
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
out := firstLine(output)
|
||||
return out == "true"
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue