Skip to content

Commit

Permalink
wrapping with a var
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisStatham committed Jul 11, 2024
1 parent bd93c5d commit 5aac59a
Showing 1 changed file with 32 additions and 28 deletions.
60 changes: 32 additions & 28 deletions internal/multigitter/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ type Runner struct {
ForkOwner string // The owner of the new fork. If empty, the fork should happen on the logged in user

ConflictStrategy ConflictStrategy // Defines what will happen if a branch already exists
UseGHAPI bool

Draft bool // If set, creates Pull Requests as draft

Expand Down Expand Up @@ -348,39 +349,42 @@ func (r *Runner) runSingleRepo(ctx context.Context, repo scm.Repository) (scm.Pu

log.Info("Pushing changes to remote")
forcePush := featureBranchExist && r.ConflictStrategy == ConflictStrategyReplace

if ghapi, ok := r.VersionController.(interface {
CommitThroughAPI(ctx context.Context, input graphql.CreateCommitOnBranchInput) error
}); ok {
var input graphql.CreateCommitOnBranchInput
input.Headline = r.CommitMessage
input.BranchName = r.FeatureBranch
array := strings.Split(repo.CloneURL(), "/")
repoName := strings.Trim(array[len(array)-1], ".git")
input.RepositoryNameWithOwner = strings.TrimSpace(fmt.Sprintf("%v/%v\n", array[len(array)-2], repoName))

if git, ok := sourceController.(interface {
Additions() map[string]string
if r.UseGHAPI {
if ghapi, ok := r.VersionController.(interface {
CommitThroughAPI(ctx context.Context, input graphql.CreateCommitOnBranchInput) error
}); ok {
fmt.Printf("%v\n", git.Additions())
input.Additions = git.Additions()
}
var input graphql.CreateCommitOnBranchInput
input.Headline = r.CommitMessage
input.BranchName = r.FeatureBranch
array := strings.Split(repo.CloneURL(), "/")
repoName := strings.Trim(array[len(array)-1], ".git")
input.RepositoryNameWithOwner = strings.TrimSpace(fmt.Sprintf("%v/%v\n", array[len(array)-2], repoName))

if git, ok := sourceController.(interface {
Additions() map[string]string
}); ok {
fmt.Printf("%v\n", git.Additions())
input.Additions = git.Additions()
}

if git, ok := sourceController.(interface {
Deletions() []string
}); ok {
input.Deletions = git.Deletions()
}
if git, ok := sourceController.(interface {
Deletions() []string
}); ok {
input.Deletions = git.Deletions()
}

if git, ok := sourceController.(interface {
OldHash() string
}); ok {
input.ExpectedHeadOid = git.OldHash()
}
if git, ok := sourceController.(interface {
OldHash() string
}); ok {
input.ExpectedHeadOid = git.OldHash()
}

err = ghapi.CommitThroughAPI(ctx, input)
err = ghapi.CommitThroughAPI(ctx, input)
} else {
log.Info("Could not find CommitThroughAPI, falling back on default push")
err = sourceController.Push(ctx, remoteName, forcePush)
}
} else {
log.Info("Could not find CommitThroughAPI, falling back on default push")
err = sourceController.Push(ctx, remoteName, forcePush)
}

Expand Down

0 comments on commit 5aac59a

Please sign in to comment.