-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathpush.go
More file actions
43 lines (34 loc) · 808 Bytes
/
push.go
File metadata and controls
43 lines (34 loc) · 808 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package main
import (
"fmt"
"os"
"os/exec"
"path"
"strings"
)
var cmdPush = &Command{
Run: runPush,
UsageLine: "push",
Short: "pushes your results to Coduno",
Long: ``,
}
func runPush(cmd *Command, args []string) {
repoBytes, err := exec.Command("git", "rev-parse", "--show-toplevel").CombinedOutput()
if err != nil {
fmt.Fprintln(os.Stderr, "I don't know what to push.")
os.Exit(2)
}
repo := path.Base(strings.Trim(string(repoBytes), "\r\n"))
remote := "git@git.cod.uno:" + repo
push := exec.Command("git", "push", remote)
push.Stdin = os.Stdin
push.Stdout = os.Stdout
push.Stderr = os.Stderr
if err = push.Start(); err != nil {
fmt.Fprintln(os.Stderr, err.Error())
return
}
if err = push.Wait(); err != nil {
fmt.Fprintln(os.Stderr, err.Error())
}
}