-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Biniam Bekele
committed
Nov 12, 2021
1 parent
dde55d6
commit 88617fd
Showing
9 changed files
with
152 additions
and
94 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package git | ||
|
||
import ( | ||
"os" | ||
"os/exec" | ||
) | ||
|
||
// GitClone clones a git repostory | ||
func Clone(baseDir, repoPath string, repoURL string) error { | ||
return Run(baseDir, "clone", repoURL, repoPath) | ||
} | ||
|
||
// GitInit initializes a git repository | ||
func Init(baseDir, repoPath string) error { | ||
return Run(baseDir, "init", repoPath) | ||
} | ||
|
||
// Is returns true if the given directory is a git repository | ||
func Is(baseDir string) bool { | ||
cmd := exec.Command("git", "rev-parse", "--git-dir") | ||
cmd.Dir = baseDir | ||
err := cmd.Run() | ||
return err == nil | ||
} | ||
|
||
// GitRun runs a git command in a repository | ||
func Run(baseDir string, arguments ...string) error { | ||
cmd := exec.Command("git", arguments...) | ||
cmd.Stdin = os.Stdin | ||
cmd.Stdout = os.Stdout | ||
cmd.Stderr = os.Stderr | ||
cmd.Dir = baseDir | ||
return cmd.Run() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters