Last active
November 16, 2018 00:19
-
-
Save kimh/21aee8751007780517249f8f09acb262 to your computer and use it in GitHub Desktop.
Revisions
-
Kim, Hirokuni revised this gist
Apr 20, 2017 . 1 changed file with 0 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -33,7 +33,6 @@ func Clone() error { _, err = git.PlainClone(directory, false, &git.CloneOptions{ URL: url, Auth: &gitssh.PublicKeys{ User: "git", Signer: signer, -
Kim, Hirokuni revised this gist
Apr 20, 2017 . 1 changed file with 1 addition and 5 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,19 +1,17 @@ package clone import ( "os" "golang.org/x/crypto/ssh" "gopkg.in/src-d/go-git.v4" gitssh "gopkg.in/src-d/go-git.v4/plumbing/transport/ssh" "io/ioutil" "testing" ) var TestSSHKey = ` your ssh key here ` // Race can be reproduced with this repo @@ -26,7 +24,6 @@ func Clone() error { url := Repo directory, _ := ioutil.TempDir("", "") defer os.RemoveAll(directory) buffer := []byte(TestSSHKey) signer, err := ssh.ParsePrivateKey(buffer) @@ -37,7 +34,6 @@ func Clone() error { _, err = git.PlainClone(directory, false, &git.CloneOptions{ URL: url, // This will automatically checkout to the branch Auth: &gitssh.PublicKeys{ User: "git", Signer: signer, -
Kim, Hirokuni revised this gist
Apr 20, 2017 . 1 changed file with 4 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -16,8 +16,12 @@ var TestSSHKey = ` PASTE YOUR SSH KEY HERE ` // Race can be reproduced with this repo var Repo = "git@github.com:kimh/trusty-test.git" // But not with this repo //var Repo = "git@github.com:octocat/hello-worId.git" func Clone() error { url := Repo directory, _ := ioutil.TempDir("", "") -
Kim, Hirokuni revised this gist
Apr 20, 2017 . 1 changed file with 3 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -16,8 +16,10 @@ var TestSSHKey = ` PASTE YOUR SSH KEY HERE ` var Repo = "git@github.com:kimh/trusty-test.git" func Clone() error { url := Repo directory, _ := ioutil.TempDir("", "") defer os.RemoveAll(directory) branchRef := plumbing.ReferenceName(fmt.Sprintf("refs/heads/%s", "master")) -
Kim, Hirokuni created this gist
Apr 20, 2017 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,55 @@ package clone import ( "fmt" "os" "golang.org/x/crypto/ssh" "gopkg.in/src-d/go-git.v4" "gopkg.in/src-d/go-git.v4/plumbing" gitssh "gopkg.in/src-d/go-git.v4/plumbing/transport/ssh" "io/ioutil" "testing" ) var TestSSHKey = ` PASTE YOUR SSH KEY HERE ` func Clone() error { url := "git@github.com:kimh/trusty-test.git" directory, _ := ioutil.TempDir("", "") defer os.RemoveAll(directory) branchRef := plumbing.ReferenceName(fmt.Sprintf("refs/heads/%s", "master")) buffer := []byte(TestSSHKey) signer, err := ssh.ParsePrivateKey(buffer) if err != nil { return err } _, err = git.PlainClone(directory, false, &git.CloneOptions{ URL: url, // This will automatically checkout to the branch ReferenceName: branchRef, Auth: &gitssh.PublicKeys{ User: "git", Signer: signer, }, Progress: os.Stdout, }) if err != nil { return err } return nil } func TestClone(t *testing.T) { err := Clone() if err != nil { t.Fatalf("Get error: %v", err) } }