@@ -37,7 +37,7 @@ type prTmpRepoContext struct {
3737 errbuf * strings.Builder // any use should be preceded by a Reset and preferably after use
3838}
3939
40- func (ctx * prTmpRepoContext ) WithCmd (cmd * gitcmd.Command ) * gitcmd.Command {
40+ func (ctx * prTmpRepoContext ) PrepareGitCmd (cmd * gitcmd.Command ) * gitcmd.Command {
4141 ctx .outbuf .Reset ()
4242 ctx .errbuf .Reset ()
4343 return cmd .WithDir (ctx .tmpBasePath ).
@@ -130,22 +130,22 @@ func createTemporaryRepoForPR(ctx context.Context, pr *issues_model.PullRequest)
130130 return nil , nil , fmt .Errorf ("Unable to add base repository to temporary repo [%s -> tmpBasePath]: %w" , pr .BaseRepo .FullName (), err )
131131 }
132132
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 )).
134134 Run (ctx ); err != nil {
135135 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 ())
136136 cancel ()
137137 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 ())
138138 }
139139
140- if err := prCtx .WithCmd (gitcmd .NewCommand ("fetch" , "origin" ).AddArguments (fetchArgs ... ).
140+ if err := prCtx .PrepareGitCmd (gitcmd .NewCommand ("fetch" , "origin" ).AddArguments (fetchArgs ... ).
141141 AddDashesAndList (git .BranchPrefix + pr .BaseBranch + ":" + git .BranchPrefix + baseBranch , git .BranchPrefix + pr .BaseBranch + ":" + git .BranchPrefix + "original_" + baseBranch )).
142142 Run (ctx ); err != nil {
143143 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 ())
144144 cancel ()
145145 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 ())
146146 }
147147
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 )).
149149 Run (ctx ); err != nil {
150150 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 ())
151151 cancel ()
@@ -158,7 +158,7 @@ func createTemporaryRepoForPR(ctx context.Context, pr *issues_model.PullRequest)
158158 return nil , nil , fmt .Errorf ("Unable to add head base repository to temporary repo [%s -> tmpBasePath]: %w" , pr .HeadRepo .FullName (), err )
159159 }
160160
161- if err := prCtx .WithCmd (gitcmd .NewCommand ("remote" , "add" ).AddDynamicArguments (remoteRepoName , headRepoPath )).
161+ if err := prCtx .PrepareGitCmd (gitcmd .NewCommand ("remote" , "add" ).AddDynamicArguments (remoteRepoName , headRepoPath )).
162162 Run (ctx ); err != nil {
163163 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 ())
164164 cancel ()
@@ -176,7 +176,7 @@ func createTemporaryRepoForPR(ctx context.Context, pr *issues_model.PullRequest)
176176 } else {
177177 headBranch = pr .GetGitHeadRefName ()
178178 }
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 )).
180180 Run (ctx ); err != nil {
181181 cancel ()
182182 if ! gitrepo .IsBranchExist (ctx , pr .HeadRepo , pr .HeadBranch ) {
0 commit comments