[v6] No longer switch branches locally and drop create_branch
, skip_fetch
and skip_checkout
options
#314
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.
Note
For folks browsing the repository and finding this PR: I've not yet merged this PR, as I haven't yet decided when and how to launch v6 of this action yet.
This pull request tackles a long standing issue with this action: how the action works with branches internally.
Since forever, the action will switch branches locally, if a branch name is provided through the
branch
-option.This leads to a slew of problems, when users write workflows, where the repo is checked out using the default branch (
main
) but the changes are then pushed to a different branch (example-branch-1
) (Example: #301).This annoyed me for a long time. There's no need to check out the given branch locally. A local branch does not have to align with the remote branch in order to push a commit to said remote branch.
We can target the right target branch in the
git-push
command.This PR changes this behaviour by removing the
_switch_to_branch
function completely.By removing the function, the action also no longer runs
git-fetch
.The test suite of the action has been adjusted accordingly. Some tests have been removed. Some tests have been rewritten, as removing the
_switch_to_branch
function changed the behaviour of the action in certain cases. See "Breaking Changes" section for details.As this is a breaking change, this change will be released in an upcoming major release (v6) of this Action.
Why I added the current behaviour of switching branches locally is a mistery to me. I probably wrote the code this way, as I personally always mirror the branch names in my local repository with my remote repository. (I would work on a branch called
feature-x
and push that toorigin/feature-x
and notorigin/development
)Potential Issues
If a user checks out a repository on it's default branch (
main
), makes changes to the repo and pushes the changes to remote branchexample
which already exists on remote and has newer commits, the action will fail to push to remote with an error message like this:The solution here will still be, that the user has to solve these "out-of-sync" issues on their own by adding a
git-pull
orgit-rebase
step in their workflows.Breaking Changes
TBD
Related Issues
create_branch
should be for remote only #295TODOs
UPGRADE.md