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

Consider adding a git hook to check for invalid commit messages #550

Open
2 tasks done
thesamprice opened this issue Aug 20, 2022 · 2 comments
Open
2 tasks done

Consider adding a git hook to check for invalid commit messages #550

thesamprice opened this issue Aug 20, 2022 · 2 comments

Comments

@thesamprice
Copy link
Contributor

Checklist (Please check before submitting)

  • I reviewed the Contributing Guide.
  • I performed a cursory search to see if the bug report is relevant, not redundant, nor in conflict with other tickets.

Describe the bug
See title, on pull requests the commit message is reworded form #zzz to nasa#zzzz

To Reproduce
Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Expected behavior
A clear and concise description of what you expected to happen.

Code snips
If applicable, add references to the software.

System observed on:

  • Hardware
  • OS: [e.g. Linux 4.4]
  • Versions [e.g. cFE 6.6, OSAL 4.2, PSP 1.3 for mcp750, any related apps]

Additional context
Add any other context about the problem here.

Reporter Info
Full name and company/organization if applicable

@skliper
Copy link
Contributor

skliper commented Aug 22, 2022

Can you link to a case where this actually failed? I haven't seen any issue like this myself, so I suspect it may be more nuanced. And/or submit example PRs that show this rejection behavior?

@thesamprice
Copy link
Contributor Author

thesamprice commented Aug 22, 2022

I think it was because i had 'fix' in the title rather than Fix.
It might be wroth adding git hooks for message formats to the repos that are enforcing this.

I think it would look like this

cat .githooks/commit-msg

#!/bin/bash
#
# Purpose: Check that message has correct format

# Check for issue tag in commit message
issue_tag_regex="^((Fix|HotFix|Part)\s\#[0-9]+,\s[a-zA-Z0-9]+|Merge\spull\srequest\s\#[0-9]+\s[a-zA-Z0-9]+|IC:\s[a-zA-Z0-9]+)"

if ! grep -qE "$issue_tag_regex" "$1"; then

    cat << EOF
ERROR - Commit message does not contain proper format
Expected Commit Format: (Fix|HotFix|Part) #ZZZ, message
EOF

    exit 1
fi

exit 0

@skliper skliper added invalid and removed invalid labels Sep 8, 2022
@skliper skliper changed the title format check fails on nasa#ZZZZ Consider adding a git hook to check for invalid commit messages Sep 8, 2022
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