-
Notifications
You must be signed in to change notification settings - Fork 139
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
4 changed files
with
18 additions
and
7 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 |
---|---|---|
|
@@ -157,6 +157,10 @@ jobs: | |
<img src="./.github/screenshots/auto-fix.png" alt="Screenshot of auto-fix commit" width="80%" /> | ||
</p> | ||
|
||
- **`git_name`**: Username for auto-fix commits. Default: `"Lint Action"` | ||
|
||
- **`git_email`**: Email address for auto-fix commits. Default: `"[email protected]"` | ||
|
||
- **`commit_message`**: Template for auto-fix commit messages. The `${linter}` variable can be used to insert the name of the linter. Default: `"Fix code style issues with ${linter}"` | ||
|
||
## Limitations | ||
|
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 |
---|---|---|
|
@@ -7,6 +7,14 @@ inputs: | |
description: Whether linters should try to fix code style issues automatically | ||
required: false | ||
default: false | ||
git_name: | ||
description: Username for auto-fix commits | ||
required: false | ||
default: Lint Action | ||
git_email: | ||
description: Email address for auto-fix commits | ||
required: false | ||
default: "[email protected]" | ||
commit_message: | ||
description: 'Template for auto-fix commit messages. The "${linter}" variable can be used to insert the name of the linter which has created the auto-fix' | ||
required: false | ||
|
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 |
---|---|---|
|
@@ -7,9 +7,6 @@ const linters = require("./linters"); | |
const { getInput, log } = require("./utils/action"); | ||
const { getSummary } = require("./utils/lint-result"); | ||
|
||
const GIT_EMAIL = "[email protected]"; | ||
const GIT_NAME = "Lint Action"; | ||
|
||
// Abort action on unhandled promise rejections | ||
process.on("unhandledRejection", (err) => { | ||
log(err, "error"); | ||
|
@@ -22,7 +19,9 @@ process.on("unhandledRejection", (err) => { | |
async function runAction() { | ||
const context = getContext(); | ||
const autoFix = getInput("auto_fix") === "true"; | ||
const commitMsg = getInput("commit_message", true); | ||
const gitName = getInput("git_name", true); | ||
const gitEmail = getInput("git_email", true); | ||
const commitMessage = getInput("commit_message", true); | ||
|
||
// If on a PR from fork: Display messages regarding action limitations | ||
if (context.eventName === "pull_request" && context.repository.hasFork) { | ||
|
@@ -40,7 +39,7 @@ async function runAction() { | |
|
||
if (autoFix) { | ||
// Set Git committer username and password | ||
git.setUserInfo(GIT_NAME, GIT_EMAIL); | ||
git.setUserInfo(gitName, gitEmail); | ||
} | ||
if (context.eventName === "pull_request") { | ||
// Fetch and check out PR branch: | ||
|
@@ -90,7 +89,7 @@ async function runAction() { | |
if (autoFix) { | ||
// Commit and push auto-fix changes | ||
if (git.hasChanges()) { | ||
git.commitChanges(commitMsg.replace(/\${linter}/g, linter.name)); | ||
git.commitChanges(commitMessage.replace(/\${linter}/g, linter.name)); | ||
git.pushChanges(); | ||
} | ||
} | ||
|