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

Allow-Empty commit argument not working #350

Closed
mcargille opened this issue Jan 21, 2022 · 2 comments · Fixed by #352
Closed

Allow-Empty commit argument not working #350

mcargille opened this issue Jan 21, 2022 · 2 comments · Fixed by #352
Assignees
Labels
good first issue Good for newcomers type: bug Verified problems that need to be worked on

Comments

@mcargille
Copy link
Contributor

mcargille commented Jan 21, 2022

Describe the bug
I am attempting to use the new commit arguments option to create an empty commit by passing in '--allow-empty'. The logs show that it is correctly evaluated as an input. The precise commit command does not seem to be printed by even detailed debug logs, but the internal logs show the normal 'Working tree clean. Nothing to commit.' message, indicating the argument was not executed.

Workflow used

- uses: EndBug/add-and-commit@v8.0.0
  with:
    commit: '--allow-empty'
    message: 'closes #${{ github.event.issue.number }}'
    new_branch: '#${{ github.event.issue.number }}-${{ github.event.issue.title }}'

Expected behavior
Expected the 'commit: --allow-empty' option to be passed to the commit command and successfully create an empty commit.

Logs
##[debug]Evaluating condition for step: 'Run EndBug/add-and-commit@v8.0.0'
##[debug]Evaluating: success()
##[debug]Evaluating success:
##[debug]=> true
##[debug]Result: true
##[debug]Starting: Run EndBug/add-and-commit@v8.0.0
##[debug]Loading inputs
##[debug]Evaluating: format('closes #{0}', github.event.issue.number)
##[debug]Evaluating format:
##[debug]..Evaluating String:
##[debug]..=> 'closes #{0}'
##[debug]..Evaluating Index:
##[debug]....Evaluating Index:
##[debug]......Evaluating Index:
##[debug]........Evaluating github:
##[debug]........=> Object
##[debug]........Evaluating String:
##[debug]........=> 'event'
##[debug]......=> Object
##[debug]......Evaluating String:
##[debug]......=> 'issue'
##[debug]....=> Object
##[debug]....Evaluating String:
##[debug]....=> 'number'
##[debug]..=> 16
##[debug]=> 'closes #16'
##[debug]Result: 'closes #16'
##[debug]Evaluating: format('#{0}-{1}', github.event.issue.number, github.event.issue.title)
##[debug]Evaluating format:
##[debug]..Evaluating String:
##[debug]..=> '#{0}-{1}'
##[debug]..Evaluating Index:
##[debug]....Evaluating Index:
##[debug]......Evaluating Index:
##[debug]........Evaluating github:
##[debug]........=> Object
##[debug]........Evaluating String:
##[debug]........=> 'event'
##[debug]......=> Object
##[debug]......Evaluating String:
##[debug]......=> 'issue'
##[debug]....=> Object
##[debug]....Evaluating String:
##[debug]....=> 'number'
##[debug]..=> 16
##[debug]..Evaluating Index:
##[debug]....Evaluating Index:
##[debug]......Evaluating Index:
##[debug]........Evaluating github:
##[debug]........=> Object
##[debug]........Evaluating String:
##[debug]........=> 'event'
##[debug]......=> Object
##[debug]......Evaluating String:
##[debug]......=> 'issue'
##[debug]....=> Object
##[debug]....Evaluating String:
##[debug]....=> 'title'
##[debug]..=> 'test'
##[debug]=> '#16-test'
##[debug]Result: '#16-test'
##[debug]Evaluating: github.token
##[debug]Evaluating Index:
##[debug]..Evaluating github:
##[debug]..=> Object
##[debug]..Evaluating String:
##[debug]..=> 'token'
##[debug]=> '***'
##[debug]Result: '***'
##[debug]Loading env
Run EndBug/add-and-commit@v8.0.0
  with:
    commit: --allow-empty
    message: closes #16
    new_branch: #16-test
    add: .
    cwd: .
    default_author: github_actor
    pathspec_error_handling: ignore
    push: true
    github_token: ***

::set-output name=committed::false
##[debug]='false'

::set-output name=commit_long_sha::
##[debug]=''

::set-output name=commit_sha::
##[debug]=''

::set-output name=pushed::false
##[debug]='false'

::set-output name=tagged::false
##[debug]='false'
Running in /home/runner/work/taskchain/taskchain
##[debug]Input parsed as single string
Add input parsed as single string, running 1 git add command.

Using 'mcargille mcargille@users.noreply.github.com' as author.
##[debug]Committer: mcargille mcargille@users.noreply.github.com
Using "closes #16" as commit message.
##[debug]Current push option: 'true' (parsed as boolean)
::group::Internal logs
Internal logs
Staging files...
Adding files...
##[debug]Input parsed as single string
##[debug]Git args parsed:
##[debug] - Original: .
##[debug] - Parsed: ["."]
No files to remove.
Checking for uncommitted changes in the git working tree...
::endgroup::
Working tree clean. Nothing to commit.
::group::Outputs
Outputs
committed: false
commit_long_sha: undefined
commit_sha: undefined
pushed: false
tagged: false
::endgroup::
##[debug]Node Action run completed with exit code 0
##[debug]Finishing: Run EndBug/add-and-commit@v8.0.0

@mcargille mcargille added the status: pending More info is needed before deciding what to do label Jan 21, 2022
@mcargille
Copy link
Contributor Author

Looks like there's an explicit check in code that the working tree is not empty, reasonably assuming that no one would be wanting to intentionally allow empty commits.

core.info('> Checking for uncommitted changes in the git working tree...')
const changedFiles = (await git.diffSummary(['--cached'])).files.length
if (changedFiles > 0) {
core.info(`> Found ${changedFiles} changed files.`)

@mcargille mcargille changed the title Commit arguments do not seem to be used Allow-Empty commit argument not working Jan 21, 2022
@EndBug EndBug self-assigned this Jan 21, 2022
@EndBug EndBug added type: bug Verified problems that need to be worked on good first issue Good for newcomers and removed status: pending More info is needed before deciding what to do labels Jan 21, 2022
@EndBug
Copy link
Owner

EndBug commented Jan 21, 2022

Hi, thanks for opening the issue!
Yeah, I totally assumed that no one would ever need to create an empty commit 😅

I don't want to allow empty commits by default, since I don't want the action to fail in that case, so I guess I could check whether the commit input contains the allow-empty option 👍🏻

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers type: bug Verified problems that need to be worked on
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants