Skip to content

Commit 391d60f

Browse files
author
Scott Schulthess
committed
invert condition
1 parent 11080e9 commit 391d60f

File tree

1 file changed

+8
-11
lines changed

1 file changed

+8
-11
lines changed

git.go

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,14 @@ func (g *GitClient) Init(branch string) error {
8989
if err := g.command("git", "config", "--global", "user.email", "concourse@local").Run(); err != nil {
9090
return fmt.Errorf("failed to configure git email: %s", err)
9191
}
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 {
95100
err := ioutil.WriteFile(filePath, []byte(g.PrivateKey), 0600)
96101
if err != nil {
97102
fmt.Println("Error writing private key:", err)
@@ -102,14 +107,6 @@ func (g *GitClient) Init(branch string) error {
102107
if err := g.command("git", "config", "credential.https://github.com.helper", helperStr).Run(); err != nil {
103108
return fmt.Errorf("failed to configure github url: %s", err)
104109
}
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)
113110
}
114111
return nil
115112
}

0 commit comments

Comments
 (0)