*gitea remote and push

This commit is contained in:
2023-04-13 15:13:38 -04:00
parent b082810d91
commit 6c03f880da
2 changed files with 126 additions and 2 deletions

22
main.go
View File

@@ -30,8 +30,13 @@ type (
Create_Remote_Repo bool
Remote_User string
Remote_Location string
Remote_Shortname string
Remote_Label string
Commands [][]string
Setup_gitea bool
Gitea_server_account string // should be in ~/.ssh/config
Gitea_ssh_host_label string
Gitea_user_account string
Remote_Label_gitea string
}
ScaffoldSetup struct {
TestKey string
@@ -235,7 +240,7 @@ func main() {
// add remote to local repo
new_remote_repo := npsetup.Remote_User + ":" + npsetup.Remote_Location + "/" + newProjectName + ".git"
_, err = exec.Command("git", "remote", "add", npsetup.Remote_Shortname, new_remote_repo).Output()
_, err = exec.Command("git", "remote", "add", npsetup.Remote_Label, new_remote_repo).Output()
ifFerr("Unable to set git remote for new repo", err)
fmt.Println("Added remote repo to git as origin")
@@ -247,6 +252,19 @@ func main() {
fmt.Println("Pushed initial commit to remote")
}
if npsetup.Setup_gitea {
// create gitea repo
grcomm := fmt.Sprintf("%s:%s/%s.git", npsetup.Gitea_ssh_host_label, npsetup.Gitea_user_account, newProjectName)
_, err = exec.Command("git", "remote", "add", npsetup.Remote_Label_gitea, grcomm).Output()
ifFerr("Unable to set git remote for new project to gitea", err)
fmt.Println("Added remote repo to git for gitea as ", npsetup.Remote_Label_gitea)
// -u sets upstream tracking
_, err = exec.Command("git", "push", "-u", npsetup.Remote_Label_gitea, "main").Output()
ifFerr("Unable to push new project to gitea", err)
fmt.Println("Pushed new project to gitea")
}
}
fmt.Printf("New %s Project: %s ready\n", projType, newProjectName)