-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
remove unnecessary push when rendering to local path #272
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -80,12 +80,12 @@ | |
logger := rc.logger.WithField("targetBranch", rc.request.TargetBranch) | ||
|
||
// Check if the target branch exists on the remote | ||
targetBranchExists, err := rc.repo.RemoteBranchExists(rc.request.TargetBranch) | ||
remoteTargetBranchExists, err := rc.repo.RemoteBranchExists(rc.request.TargetBranch) | ||
if err != nil { | ||
return fmt.Errorf("error checking for existence of target branch: %w", err) | ||
return fmt.Errorf("error checking for existence of remote target branch: %w", err) | ||
} | ||
|
||
if targetBranchExists { | ||
if remoteTargetBranchExists { | ||
logger.Debug("target branch exists on remote") | ||
if err = rc.repo.Fetch(); err != nil { | ||
return fmt.Errorf("error fetching from remote: %w", err) | ||
|
@@ -103,10 +103,31 @@ | |
} | ||
|
||
logger.Debug("target branch does not exist on remote") | ||
if err = rc.repo.CreateOrphanedBranch(rc.request.TargetBranch); err != nil { | ||
return fmt.Errorf("error creating new target branch: %w", err) | ||
|
||
// Check if the target branch exists locally | ||
localTargetBranchExists, err := rc.repo.LocalBranchExists(rc.request.TargetBranch) | ||
if err != nil { | ||
return fmt.Errorf("error checking for existence of local target branch: %w", err) | ||
} | ||
logger.Debug("created target branch") | ||
|
||
if localTargetBranchExists { | ||
logger.Debug("target branch exists locally") | ||
if err = rc.repo.Checkout(rc.request.TargetBranch); err != nil { | ||
return fmt.Errorf("error checking out target branch: %w", err) | ||
} | ||
logger.Debug("checked out target branch") | ||
} else { | ||
logger.Debug("target branch does not exist locally") | ||
if err = rc.repo.CreateOrphanedBranch(rc.request.TargetBranch); err != nil { | ||
return fmt.Errorf("error creating new target branch: %w", err) | ||
} | ||
logger.Debug("created target branch locally") | ||
} | ||
|
||
if rc.request.LocalOutPath != "" { | ||
return nil // There's no need to push the new branch to the remote | ||
} | ||
Comment on lines
+127
to
+129
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is the important bit. |
||
|
||
if err = rc.repo.Commit( | ||
"Initial commit", | ||
&git.CommitOptions{ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added for good measure; instead of blindly creating an orphan branch.