@@ -36,13 +36,13 @@ func NewGitClient(source *Source, dir string, output io.Writer) (*GitClient, err
36
36
os .Setenv ("GIT_LFS_SKIP_SMUDGE" , "true" )
37
37
}
38
38
return & GitClient {
39
- AccessToken : source .AccessToken ,
40
- PrivateKey : source .PrivateKey ,
41
- UseGithubApp : source .UseGitHubApp ,
42
- ApplicationID : source .ApplicationID ,
39
+ AccessToken : source .AccessToken ,
40
+ PrivateKey : source .PrivateKey ,
41
+ UseGithubApp : source .UseGitHubApp ,
42
+ ApplicationID : source .ApplicationID ,
43
43
GithubOrganziation : source .GithubOrganziation ,
44
- Directory : dir ,
45
- Output : output ,
44
+ Directory : dir ,
45
+ Output : output ,
46
46
}, nil
47
47
}
48
48
@@ -63,8 +63,12 @@ func (g *GitClient) command(name string, arg ...string) *exec.Cmd {
63
63
cmd .Stdout = g .Output
64
64
cmd .Stderr = g .Output
65
65
cmd .Env = os .Environ ()
66
+ if ! g .UseGithubApp {
67
+ cmd .Env = append (cmd .Env ,
68
+ "X_OAUTH_BASIC_TOKEN=" + g .AccessToken )
69
+ }
70
+
66
71
cmd .Env = append (cmd .Env ,
67
- "X_OAUTH_BASIC_TOKEN=" + g .AccessToken ,
68
72
"GIT_ASKPASS=/usr/local/bin/askpass.sh" )
69
73
fmt .Fprint (os .Stderr , fmt .Sprintf ("\n %s %v" , name , arg ))
70
74
@@ -95,7 +99,6 @@ func (g *GitClient) Init(branch string) error {
95
99
}
96
100
97
101
helperStr := fmt .Sprintf ("!git-credential-github-app --appId %d -organization %s -username x-access-token -privateKeyFile /tmp/git-resource-private-key" , g .ApplicationID , g .GithubOrganziation )
98
- fmt .Fprint (os .Stderr , "\n sds helperStr" , helperStr )
99
102
if err := g .command ("git" , "config" , "credential.https://github.com.helper" , helperStr ).Run (); err != nil {
100
103
return fmt .Errorf ("failed to configure github url: %s" , err )
101
104
}
@@ -254,6 +257,9 @@ func (g *GitClient) Endpoint(uri string) (string, error) {
254
257
if err != nil {
255
258
return "" , fmt .Errorf ("failed to parse commit url: %s" , err )
256
259
}
257
- //endpoint.User = url.UserPassword("x-oauth-basic", g.AccessToken)
260
+ if ! g .UseGithubApp {
261
+ endpoint .User = url .UserPassword ("x-oauth-basic" , g .AccessToken )
262
+ }
263
+
258
264
return endpoint .String (), nil
259
265
}
0 commit comments