forked from owenthereal/ccat
/
push_cmd.go
46 lines (37 loc) · 1.04 KB
/
push_cmd.go
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
44
45
46
package src
import (
"log"
"github.com/jingweno/ccat/Godeps/_workspace/src/sourcegraph.com/sourcegraph/go-sourcegraph/sourcegraph"
)
func init() {
_, err := CLI.AddCommand("push",
"upload and import the current commit (to a remote)",
"The push command uploads and imports the current repository commit's build data to a remote. It is a wrapper around `src build-data upload` and `src remote import-build`.",
&pushCmd,
)
if err != nil {
log.Fatal(err)
}
}
type PushCmd struct {
}
var pushCmd PushCmd
func (c *PushCmd) Execute(args []string) error {
cl := NewAPIClientWithAuthIfPresent()
rrepo, err := getRemoteRepo(cl)
if err != nil {
return err
}
repoSpec := sourcegraph.RepoSpec{URI: rrepo.URI}
repoRevSpec := sourcegraph.RepoRevSpec{RepoSpec: repoSpec, Rev: localRepo.CommitID}
if _, err := getCommitWithRefreshAndRetry(cl, repoRevSpec); err != nil {
return err
}
if err := buildDataUploadCmd.Execute(nil); err != nil {
return err
}
if err := remoteImportBuildCmd.Execute(nil); err != nil {
return err
}
return nil
}