-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Push changes if detected
- Loading branch information
Showing
1 changed file
with
2 additions
and
9 deletions.
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 |
---|---|---|
|
@@ -19,24 +19,20 @@ jobs: | |
- name: Format code with Black | ||
uses: psf/black@stable | ||
with: | ||
options: "." # Options for Black (e.g., --line-length) | ||
src: "." # The directory to format (entire repo) | ||
options: "." | ||
src: "." | ||
|
||
- name: Check for changes | ||
id: check_changes | ||
run: | | ||
# Check if there are code changes after formatting | ||
git diff --exit-code || echo "Code changes detected" | ||
continue-on-error: true | ||
|
||
- name: Commit formatted code | ||
if: steps.check_changes.outputs.exit_code != '0' | ||
run: | | ||
# Configure Git user | ||
git config --local user.email "[email protected]" | ||
git config --local user.name "GitHub Actions" | ||
# Add and commit changes if any | ||
git add . | ||
git diff --quiet && git diff --staged --quiet || git commit -m "Format code with Black" | ||
|
@@ -49,10 +45,7 @@ jobs: | |
- name: Display changes and success message | ||
if: steps.check_changes.outputs.exit_code != '0' | ||
run: | | ||
# Show a summary of the changes made by Black | ||
echo "The code has been successfully formatted with Black." | ||
echo "The following changes were made:" | ||
git diff --name-only HEAD~1 HEAD | ||
# Display success message | ||
echo "Code formatting completed successfully and changes have been pushed." |