@@ -3,9 +3,11 @@ package vcs
33import (
44 "context"
55 "fmt"
6- "github.com/machinebox/graphql"
76 "os/exec"
87 "strings"
8+
9+ "github.com/commitdev/zero/pkg/util/flog"
10+ "github.com/machinebox/graphql"
911)
1012
1113// InitializeRepository Creates and initializes a github repository for the given url
@@ -53,19 +55,19 @@ func InitializeRepository(repositoryUrl string, githubApiKey string) {
5355 return
5456 }
5557
56- fmt . Printf ( " Repository successfully created and initialized for module : %s\n " , repositoryName )
58+ flog . Infof ( ":check_mark_button: Repository created: %s" , repositoryUrl )
5759}
5860
5961// parseRepositoryUrl extracts the owner name and repository name from a repository url.
6062// repositoryUrl is expected to be in the format "github.com/{ownerName}/{repositoryName}"
6163func parseRepositoryUrl (repositoryUrl string ) (string , string , error ) {
6264 if len (repositoryUrl ) == 0 {
63- return "" ,"" , fmt .Errorf ("invalid repository url. expected format \" github.com/{ownerName}/{repositoryName}\" " )
65+ return "" , "" , fmt .Errorf ("invalid repository url. expected format \" github.com/{ownerName}/{repositoryName}\" " )
6466 }
6567
6668 segments := strings .Split (repositoryUrl , "/" )
6769 if len (segments ) != 3 {
68- return "" ,"" , fmt .Errorf ("invalid repository url. expected format \" github.com/{ownerName}/{repositoryName}\" " )
70+ return "" , "" , fmt .Errorf ("invalid repository url. expected format \" github.com/{ownerName}/{repositoryName}\" " )
6971 }
7072
7173 ownerName := segments [1 ]
@@ -77,10 +79,10 @@ func parseRepositoryUrl(repositoryUrl string) (string, string, error) {
7779const createPersonalRepositoryMutation = `mutation ($repoName: String!, $repoDescription: String!) {
7880 createRepository(
7981 input: {
80- name:$repoName,
81- visibility: PRIVATE,
82+ name:$repoName,
83+ visibility: PRIVATE,
8284 description: $repoDescription
83- })
85+ })
8486 {
8587 clientMutationId
8688 }
@@ -89,11 +91,11 @@ const createPersonalRepositoryMutation = `mutation ($repoName: String!, $repoDes
8991const createOrganizationRepositoryMutation = `mutation ($repoName: String!, $repoDescription: String!, $ownerId: String!) {
9092 createRepository(
9193 input: {
92- name:$repoName,
93- visibility: PRIVATE,
94+ name:$repoName,
95+ visibility: PRIVATE,
9496 description: $repoDescription
9597 ownerId: $ownerId
96- })
98+ })
9799 {
98100 clientMutationId
99101 }
@@ -183,21 +185,23 @@ func doInitialCommit(ownerName string, repositoryName string) error {
183185 }
184186
185187 for _ , command := range commands {
186- fmt .Printf (">> %s\n " , command .description )
188+ // TODO: Debug-level logging?
189+ // fmt.Printf(">> %s\n", command.description)
187190
188191 cmd := exec .Command (command .command , command .args ... )
189192 cmd .Dir = "./" + repositoryName
190- out , err := cmd .CombinedOutput ()
193+ _ , err := cmd .CombinedOutput ()
191194 if err != nil {
192195 fmt .Printf ("ERROR: failed to run %s: %s\n " , command .description , err .Error ())
193196 // this is a partial failure. some commands may have exec'ed successfully.
194197 break
195- } else {
196- response := string (out )
197- if len (response ) > 0 {
198- fmt .Println (response )
199- }
200- }
198+ } //else {
199+ // TODO: Debug-level logging?
200+ // response := string(out)
201+ // if len(response) > 0 {
202+ // fmt.Println(response)
203+ // }
204+ // }
201205 }
202206
203207 return nil
0 commit comments