aboutsummaryrefslogtreecommitdiffstats
path: root/examples/common_test.go
diff options
context:
space:
mode:
authorSantiago M. Mola <santi@mola.io>2016-12-19 23:36:44 +0100
committerMáximo Cuadros <mcuadros@gmail.com>2016-12-19 23:36:44 +0100
commit90d67bb648ae32d5b1a0f7b1af011da6dfb24315 (patch)
treefc8c14e82974be6ff49e842328ec3206ebf1b4c2 /examples/common_test.go
parent725ade0de6f60549e65cc4d94094b1f5ed48587f (diff)
downloadgo-git-90d67bb648ae32d5b1a0f7b1af011da6dfb24315.tar.gz
remote: add Push (#178)
* remote: add Push. * add Push method to Remote. * add method Push to Repository. * examples: add push example. * requested changes * add tests, fixes
Diffstat (limited to 'examples/common_test.go')
-rw-r--r--examples/common_test.go23
1 files changed, 23 insertions, 0 deletions
diff --git a/examples/common_test.go b/examples/common_test.go
index e75b492..9ec1f05 100644
--- a/examples/common_test.go
+++ b/examples/common_test.go
@@ -2,6 +2,7 @@ package examples
import (
"flag"
+ "fmt"
"go/build"
"io/ioutil"
"os"
@@ -20,6 +21,7 @@ var args = map[string][]string{
"clone": []string{defaultURL, tempFolder()},
"progress": []string{defaultURL, tempFolder()},
"open": []string{filepath.Join(cloneRepository(defaultURL, tempFolder()), ".git")},
+ "push": []string{setEmptyRemote(filepath.Join(cloneRepository(defaultURL, tempFolder()), ".git"))},
}
var ignored = map[string]bool{
@@ -85,6 +87,27 @@ func cloneRepository(url, folder string) string {
return folder
}
+func createBareRepository(dir string) string {
+ cmd := exec.Command("git", "init", "--bare", dir)
+ err := cmd.Run()
+ CheckIfError(err)
+
+ return dir
+}
+
+func setEmptyRemote(dir string) string {
+ remote := createBareRepository(tempFolder())
+ setRemote(dir, fmt.Sprintf("file://%s", remote))
+ return dir
+}
+
+func setRemote(local, remote string) {
+ cmd := exec.Command("git", "remote", "set-url", "origin", remote)
+ cmd.Dir = local
+ err := cmd.Run()
+ CheckIfError(err)
+}
+
func testExample(t *testing.T, name, example string) {
cmd := exec.Command("go", append([]string{
"run", filepath.Join(example),