-
Notifications
You must be signed in to change notification settings - Fork 11
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
feat: add pr title validation feature #65
Closed
Closed
Changes from 11 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
0e42208
docs: update docker setup documentations
sujoypal144 44b61b1
docs: update docker setup documentations
sujoypal144 6da0839
docs: update docker setup documentations
sujoypal144 f4f8fb6
docs: update docker setup documentations
sujoypal144 16d4bdc
docs: update docker setup documentations
sujoypal144 47385e3
docs: update docker setup documentations
sujoypal144 45e07a1
docs: update docker setup documentations
sujoypal144 52b2870
docs: update docker setup documentations
sujoypal144 f092158
docs: update docker setup documentations
sujoypal144 73f997a
docs: update docker setup documentations
sujoypal144 76a4b60
feat: add pr title validation feature
sujoypal144 fb5a811
fix: update the run validation script command for the workflow
sujoypal144 5c33b7f
Merge branch 'main' into pr-title-validation
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
name: PR Title Validation | ||
|
||
on: | ||
pull_request: | ||
types: [opened, reopened, edited] | ||
|
||
jobs: | ||
validate_title: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
|
||
- name: Run validation script | ||
run: python validate_title.py "${{ github.event.pull_request.title }}" | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import re | ||
import sys | ||
|
||
def validate_title(title): | ||
print("The title is:", title) | ||
prefix_pattern = r'^(build|chore|ci|docs|feat|fix|perf|refactor|style|test|sample)[:\s].+' | ||
max_length = 50 | ||
|
||
match = re.match(prefix_pattern, title, re.IGNORECASE) | ||
print("Match:", match) | ||
|
||
if not match: | ||
print("PR title must start with one of the following prefixes: build, chore, ci, docs, feat, fix, perf, refactor, style, test, sample", file=sys.stderr) | ||
sys.exit(1) | ||
|
||
title_content = title.split(':', 1)[-1].strip() | ||
print("Title Content:", title_content) | ||
|
||
if len(title_content) > max_length: | ||
print(f"PR title content must not exceed {max_length} characters", file=sys.stderr) | ||
sys.exit(1) | ||
|
||
if __name__ == "__main__": | ||
title = sys.argv[1] | ||
validate_title(title) |
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Avoid direct interpolation of user input in the
run
command to prevent potential security risks.Committable suggestion
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have updated the code as per the suggestion.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sujoy-pal144, thank you for updating the code as suggested! It's great to see the security enhancement in place. If you need further assistance or have more questions, feel free to ask. Happy coding! 🚀
If you found this review helpful, would you consider giving us a shout-out on X?
Thank you for using CodeRabbit!