@@ -37,7 +37,7 @@ type prTmpRepoContext struct {
37
37
errbuf * strings.Builder // any use should be preceded by a Reset and preferably after use
38
38
}
39
39
40
- func (ctx * prTmpRepoContext ) WithCmd (cmd * gitcmd.Command ) * gitcmd.Command {
40
+ func (ctx * prTmpRepoContext ) PrepareGitCmd (cmd * gitcmd.Command ) * gitcmd.Command {
41
41
ctx .outbuf .Reset ()
42
42
ctx .errbuf .Reset ()
43
43
return cmd .WithDir (ctx .tmpBasePath ).
@@ -130,22 +130,22 @@ func createTemporaryRepoForPR(ctx context.Context, pr *issues_model.PullRequest)
130
130
return nil , nil , fmt .Errorf ("Unable to add base repository to temporary repo [%s -> tmpBasePath]: %w" , pr .BaseRepo .FullName (), err )
131
131
}
132
132
133
- if err := prCtx .WithCmd (gitcmd .NewCommand ("remote" , "add" , "-t" ).AddDynamicArguments (pr .BaseBranch ).AddArguments ("-m" ).AddDynamicArguments (pr .BaseBranch ).AddDynamicArguments ("origin" , baseRepoPath )).
133
+ if err := prCtx .PrepareGitCmd (gitcmd .NewCommand ("remote" , "add" , "-t" ).AddDynamicArguments (pr .BaseBranch ).AddArguments ("-m" ).AddDynamicArguments (pr .BaseBranch ).AddDynamicArguments ("origin" , baseRepoPath )).
134
134
Run (ctx ); err != nil {
135
135
log .Error ("%-v Unable to add base repository as origin [%s -> %s]: %v\n %s\n %s" , pr , pr .BaseRepo .FullName (), tmpBasePath , err , prCtx .outbuf .String (), prCtx .errbuf .String ())
136
136
cancel ()
137
137
return nil , nil , fmt .Errorf ("Unable to add base repository as origin [%s -> tmpBasePath]: %w\n %s\n %s" , pr .BaseRepo .FullName (), err , prCtx .outbuf .String (), prCtx .errbuf .String ())
138
138
}
139
139
140
- if err := prCtx .WithCmd (gitcmd .NewCommand ("fetch" , "origin" ).AddArguments (fetchArgs ... ).
140
+ if err := prCtx .PrepareGitCmd (gitcmd .NewCommand ("fetch" , "origin" ).AddArguments (fetchArgs ... ).
141
141
AddDashesAndList (git .BranchPrefix + pr .BaseBranch + ":" + git .BranchPrefix + baseBranch , git .BranchPrefix + pr .BaseBranch + ":" + git .BranchPrefix + "original_" + baseBranch )).
142
142
Run (ctx ); err != nil {
143
143
log .Error ("%-v Unable to fetch origin base branch [%s:%s -> base, original_base in %s]: %v:\n %s\n %s" , pr , pr .BaseRepo .FullName (), pr .BaseBranch , tmpBasePath , err , prCtx .outbuf .String (), prCtx .errbuf .String ())
144
144
cancel ()
145
145
return nil , nil , fmt .Errorf ("Unable to fetch origin base branch [%s:%s -> base, original_base in tmpBasePath]: %w\n %s\n %s" , pr .BaseRepo .FullName (), pr .BaseBranch , err , prCtx .outbuf .String (), prCtx .errbuf .String ())
146
146
}
147
147
148
- if err := prCtx .WithCmd (gitcmd .NewCommand ("symbolic-ref" ).AddDynamicArguments ("HEAD" , git .BranchPrefix + baseBranch )).
148
+ if err := prCtx .PrepareGitCmd (gitcmd .NewCommand ("symbolic-ref" ).AddDynamicArguments ("HEAD" , git .BranchPrefix + baseBranch )).
149
149
Run (ctx ); err != nil {
150
150
log .Error ("%-v Unable to set HEAD as base branch in [%s]: %v\n %s\n %s" , pr , tmpBasePath , err , prCtx .outbuf .String (), prCtx .errbuf .String ())
151
151
cancel ()
@@ -158,7 +158,7 @@ func createTemporaryRepoForPR(ctx context.Context, pr *issues_model.PullRequest)
158
158
return nil , nil , fmt .Errorf ("Unable to add head base repository to temporary repo [%s -> tmpBasePath]: %w" , pr .HeadRepo .FullName (), err )
159
159
}
160
160
161
- if err := prCtx .WithCmd (gitcmd .NewCommand ("remote" , "add" ).AddDynamicArguments (remoteRepoName , headRepoPath )).
161
+ if err := prCtx .PrepareGitCmd (gitcmd .NewCommand ("remote" , "add" ).AddDynamicArguments (remoteRepoName , headRepoPath )).
162
162
Run (ctx ); err != nil {
163
163
log .Error ("%-v Unable to add head repository as head_repo [%s -> %s]: %v\n %s\n %s" , pr , pr .HeadRepo .FullName (), tmpBasePath , err , prCtx .outbuf .String (), prCtx .errbuf .String ())
164
164
cancel ()
@@ -176,7 +176,7 @@ func createTemporaryRepoForPR(ctx context.Context, pr *issues_model.PullRequest)
176
176
} else {
177
177
headBranch = pr .GetGitHeadRefName ()
178
178
}
179
- if err := prCtx .WithCmd (gitcmd .NewCommand ("fetch" ).AddArguments (fetchArgs ... ).AddDynamicArguments (remoteRepoName , headBranch + ":" + trackingBranch )).
179
+ if err := prCtx .PrepareGitCmd (gitcmd .NewCommand ("fetch" ).AddArguments (fetchArgs ... ).AddDynamicArguments (remoteRepoName , headBranch + ":" + trackingBranch )).
180
180
Run (ctx ); err != nil {
181
181
cancel ()
182
182
if ! gitrepo .IsBranchExist (ctx , pr .HeadRepo , pr .HeadBranch ) {
0 commit comments