-
-
Notifications
You must be signed in to change notification settings - Fork 256
[v6] No longer switch branches locally and drop create_branch
, skip_fetch
and skip_checkout
options
#314
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
Conversation
@stefanzweifel are you planning to release v6 anytime soon? |
@ashleycaselli I think I will tag a new release in February/March 2025. Do the mentioned options mentioned here cause any problems for you right now? |
reame.md still uses v5 an doesn't reflect yaml changes needed to be done for the action to work |
@cforiguar thanks! I will update the README asap. Edit: Updated the README in f9017b2. The 3 input options had been removed previously from the README. If you run into a problem, you have to be more specific than just "doesn't work". |
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
The following options have been removed from git-auto-commit and can be removed from your workflows.
create_branch
(git-auto-commit no longer switches branches locally during a workflow run)skip_fetch
skip_checkout
Related Issues
create_branch
should be for remote only #295TODOs
UPGRADE.md