use remote to push instead of repo
This commit is contained in:
parent
6c137ddc27
commit
5841552c3c
1 changed files with 7 additions and 7 deletions
14
main.go
14
main.go
|
@ -121,10 +121,9 @@ func CreateRemote(
|
||||||
|
|
||||||
func Push(
|
func Push(
|
||||||
auth *githttp.BasicAuth,
|
auth *githttp.BasicAuth,
|
||||||
repo *git.Repository,
|
remote *git.Remote,
|
||||||
) error {
|
) error {
|
||||||
return repo.Push(&git.PushOptions{
|
return remote.Push(&git.PushOptions{
|
||||||
RemoteName: DefaultRemoteName,
|
|
||||||
Auth: auth,
|
Auth: auth,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -157,7 +156,7 @@ func main() {
|
||||||
"",
|
"",
|
||||||
"password",
|
"password",
|
||||||
)
|
)
|
||||||
remote := flag.String(
|
remoteUrl := flag.String(
|
||||||
"remote",
|
"remote",
|
||||||
"",
|
"",
|
||||||
"remote",
|
"remote",
|
||||||
|
@ -192,7 +191,7 @@ func main() {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
log.Printf("Downloaded %s", padurl)
|
log.Printf("Downloaded %s", padurl)
|
||||||
if _, err := Commit(tree, padfile, *remote); err != nil {
|
if _, err := Commit(tree, padfile, *remoteUrl); err != nil {
|
||||||
if err == NothingToDo {
|
if err == NothingToDo {
|
||||||
log.Printf("Nothing to do for %s", padfile)
|
log.Printf("Nothing to do for %s", padfile)
|
||||||
} else {
|
} else {
|
||||||
|
@ -210,12 +209,13 @@ func main() {
|
||||||
Password: *password,
|
Password: *password,
|
||||||
}
|
}
|
||||||
|
|
||||||
if _, err := CreateRemote(repo, *remote); err != nil {
|
remote, err := CreateRemote(repo, *remoteUrl)
|
||||||
|
if err != nil {
|
||||||
log.Fatalf("%s", err)
|
log.Fatalf("%s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if *push == true {
|
if *push == true {
|
||||||
if err := Push(auth, repo); err != nil {
|
if err := Push(auth, remote); err != nil {
|
||||||
if err == git.NoErrAlreadyUpToDate {
|
if err == git.NoErrAlreadyUpToDate {
|
||||||
log.Println("Already up-to-date")
|
log.Println("Already up-to-date")
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue