Skip to content
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

Using --amend as commit_options doesn't work when working directory is clean #82

Closed
goetzc opened this issue Jun 23, 2020 · 8 comments · Fixed by #84
Closed

Using --amend as commit_options doesn't work when working directory is clean #82

goetzc opened this issue Jun 23, 2020 · 8 comments · Fixed by #84

Comments

@goetzc
Copy link

goetzc commented Jun 23, 2020

Hello, thanks for this Action. I'm experiencing some kind of unexpected behavior when using the --amend Git option, which I'm describing below.

Version of the Action
v4.3.0

Describe the bug
When using the --amend Git commit option on the commit_options field, the Action doesn't work if the working directory is clean, showing the message "Working tree clean. Nothing to commit.".

To Reproduce
Steps to reproduce the behavior:

  • Use the --amend option on the commit_options field.
  • When the working directory is empty, nothing is changed.

Expected behavior
The commit should be amended and pushed.

Used Workflow

# Some previews manual Git changes …

    - name: Commit changes
      uses: stefanzweifel/git-auto-commit-action@v4.3.0
      with:
        commit_message: Bump version to ${{ steps.git-version.outputs.tag }}
        commit_options: --amend  # <-- This is 
        tagging_message: ${{ steps.git-version.outputs.tag }}

Additional context
My purpose is to perform some Git operations generating a new commit, and finally using this action and the --amend option to modify the commit and push it.

@goetzc
Copy link
Author

goetzc commented Jun 23, 2020

A possible solution would be to add an optional parameter to be run on the _git_is_dirty function, an renaming the function probably to _precheck, having as default value the current behavior. WDYT?

@stefanzweifel
Copy link
Owner

@goetzc What would you suggest would be an optional parameter which could be passed to _git_is_dirty or _precheck?

Maybe we could add a check_for_changes-option. By default the value is true and [ -n "$(git status -s)" ] will be executed. By setting this to false, we won't check for changes and start creating the commit and pushing it to remote.

@goetzc
Copy link
Author

goetzc commented Jun 24, 2020

The check_for_changes option would archive the target, but would not give more options for a potential precheck, although it is easier to use and disable.

@goetzc What would you suggest would be an optional parameter which could be passed to _git_is_dirty or _precheck?

I was thinking about the current check [ -n "$(git status -s)" ], to maintain the same functionality. To disable it with true, but this is counter intuitive.

@stefanzweifel
Copy link
Owner

@goetzc I think I will create a branch with my change over the next 1-2 days so you can test things out.

Will probably update the name of the option to make it more intuitive.

@goetzc
Copy link
Author

goetzc commented Jun 24, 2020

Sound great @stefanzweifel! Looking forward to test it.

Thanks

@stefanzweifel
Copy link
Owner

@goetzc

I've prepared a "skip dirty check" option in #84. You can test it by updating your workflow to use the branch:

-uses: stefanzweifel/git-auto-commit-action@v4.3.0
+uses: stefanzweifel/git-auto-commit-action@feature/skip-dirty-check

Does this help with your use case?

@goetzc
Copy link
Author

goetzc commented Jun 26, 2020

This indeed helps, thank you very much @stefanzweifel!

@stefanzweifel
Copy link
Owner

@goetzc Thanks for the feedback. I've tagged a new release: https://github.com/stefanzweifel/git-auto-commit-action/releases/tag/v4.4.0

You can update your workflow to use the exact version number:

uses: stefanzweifel/git-auto-commit-action@v4.4.0

or you can choose to always use the latest release in v4:

uses: stefanzweifel/git-auto-commit-action@v4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants