Skip to content

Commit 0a0a358

Browse files
meiji163pxrth9
andauthored
rewrite gh repo create (cli#4578)
Co-authored-by: Parth Patel <ppatil91099@gmail.com>
1 parent 6c12f34 commit 0a0a358

File tree

3 files changed

+808
-1034
lines changed

3 files changed

+808
-1034
lines changed

git/git.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,16 @@ func ToplevelDir() (string, error) {
366366

367367
}
368368

369+
// ToplevelDirFromPath returns the top-level given path of the current repository
370+
func GetDirFromPath(p string) (string, error) {
371+
showCmd, err := GitCommand("-C", p, "rev-parse", "--git-dir")
372+
if err != nil {
373+
return "", err
374+
}
375+
output, err := run.PrepareCmd(showCmd).Output()
376+
return firstLine(output), err
377+
}
378+
369379
func PathFromRepoRoot() string {
370380
showCmd, err := GitCommand("rev-parse", "--show-prefix")
371381
if err != nil {

0 commit comments

Comments
 (0)