This repository has been archived by the owner on Jan 28, 2020. It is now read-only.
-
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.
since libgit2 does not expose cloning with --depth, I can't use it for larger repos. see libgit2/libgit2#3058 I would love to switch to git2go once this is solved.
- Loading branch information
Showing
7 changed files
with
56 additions
and
225 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,31 @@ | ||
package repo | ||
|
||
import ( | ||
"fmt" | ||
"io/ioutil" | ||
"os" | ||
"os/exec" | ||
) | ||
|
||
func Clone(accessToken, owner, repo string) (string, error) { | ||
dir, err := ioutil.TempDir("", fmt.Sprintf("gh-%s-%s", owner, repo)) | ||
if err != nil { | ||
return "", err | ||
} | ||
|
||
cmds := [][]string{ | ||
[]string{"git", "init"}, | ||
[]string{"git", "pull", fmt.Sprintf("https://%s@github.com/%s/%s.git", accessToken, owner, repo), "--depth", "1"}, | ||
} | ||
|
||
for _, args := range cmds { | ||
cmd := exec.Command(args[0], args[1:]...) | ||
cmd.Dir = dir | ||
cmd.Env = os.Environ() | ||
if err := cmd.Run(); err != nil { | ||
return "", err | ||
} | ||
} | ||
|
||
return dir, nil | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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
Submodule git2go
deleted from
1670c4