@@ -89,9 +89,14 @@ func (g *GitClient) Init(branch string) error {
89
89
if err := g .command ("git" , "config" , "--global" , "user.email" , "concourse@local" ).Run (); err != nil {
90
90
return fmt .Errorf ("failed to configure git email: %s" , err )
91
91
}
92
-
93
- if g .UseGithubApp {
94
- filePath := "/tmp/git-resource-private-key"
92
+ if err := g .command ("git" , "config" , "--global" , "url.https://.insteadOf" , "git://" ).Run (); err != nil {
93
+ return fmt .Errorf ("failed to configure github url: %s" , err )
94
+ }
95
+ if ! g .UseGithubApp {
96
+ if err := g .
command (
"git" ,
"config" ,
"url.https://[email protected] /.insteadOf" ,
"[email protected] :" ).
Run ();
err != nil {
97
+ return fmt .Errorf ("failed to configure github url: %s" , err )
98
+ }
99
+ } else {
95
100
err := ioutil .WriteFile (filePath , []byte (g .PrivateKey ), 0600 )
96
101
if err != nil {
97
102
fmt .Println ("Error writing private key:" , err )
@@ -102,14 +107,6 @@ func (g *GitClient) Init(branch string) error {
102
107
if err := g .command ("git" , "config" , "credential.https://github.com.helper" , helperStr ).Run (); err != nil {
103
108
return fmt .Errorf ("failed to configure github url: %s" , err )
104
109
}
105
- } else {
106
- if err := g .
command (
"git" ,
"config" ,
"url.https://[email protected] /.insteadOf" ,
"[email protected] :" ).
Run ();
err != nil {
107
- return fmt .Errorf ("failed to configure github url: %s" , err )
108
- }
109
- }
110
-
111
- if err := g .command ("git" , "config" , "--global" , "url.https://.insteadOf" , "git://" ).Run (); err != nil {
112
- return fmt .Errorf ("failed to configure github url: %s" , err )
113
110
}
114
111
return nil
115
112
}
0 commit comments