Skip to content

Commit

Permalink
#133 all changes related to diff
Browse files Browse the repository at this point in the history
  • Loading branch information
JJ committed Apr 19, 2024
1 parent b92a795 commit d1c81da
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 10 deletions.
9 changes: 6 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Check PR
uses: JJ/github-pr-contains-action@releases/v14
uses: JJ/github-pr-contains-action@releases/v14.1
with:
github-token: ${{github.token}}
bodyDoesNotContain: "Delete|this"
Expand Down Expand Up @@ -93,7 +93,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Check that any new contributor links to their github page
uses: JJ/github-pr-contains-action@releases/v14
uses: JJ/github-pr-contains-action@releases/v14.1
with:
github-token: ${{github.token}}
linesChanged: 1
Expand Down Expand Up @@ -180,7 +180,10 @@ There are several forks of this action, with additional features:
- `v11`: Adds a configuration variable that skips users, with dependabot skipped by default (or passed through).
- `v12`: Make compatible with private repos. Upgrade to latest github API.
- `v13`: Fixes the use of `waivedUsers` which didn't actually work.
- `v14`: Eliminates setting of environment variables, documents using action output.
- `v14`: Eliminates setting of environment variables, documents using action
output.
- `v14.1`: Refrains from doing diff stuff if no variable related to diff has
been set

## License

Expand Down
6 changes: 3 additions & 3 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,11 +124,12 @@ function run() {
}
const diffContains = core.getInput("diffContains");
const diffDoesNotContain = core.getInput("diffDoesNotContain");
if (diffContains || diffDoesNotContain) {
const linesChanged = +core.getInput("linesChanged");
const filesChanged = +core.getInput("filesChanged");
if (diffContains || diffDoesNotContain || filesChanged || linesChanged) {
core.info("Checking diff contents");
const parsedDiff = yield getDiff(octokit, repository, pull_request);
core.setOutput("numberOfFiles", parsedDiff.length);
const filesChanged = +core.getInput("filesChanged");
if (filesChanged && parsedDiff.length != filesChanged) {
core.setFailed("You should change exactly " + filesChanged + " file(s)");
}
Expand All @@ -154,7 +155,6 @@ function run() {
core.setFailed("The added code should not contain " + diffDoesNotContain);
}
core.info("Checking lines/files changed");
const linesChanged = +core.getInput("linesChanged");
if (linesChanged && additions != linesChanged) {
const this_msg = "You should change exactly " +
linesChanged +
Expand Down
2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,13 @@ async function run() {

const diffContains = core.getInput("diffContains");
const diffDoesNotContain = core.getInput("diffDoesNotContain");
const linesChanged = +core.getInput("linesChanged");
const filesChanged = +core.getInput("filesChanged");

if (diffContains || diffDoesNotContain) {
if (diffContains || diffDoesNotContain || filesChanged || linesChanged) {
core.info("Checking diff contents");
const parsedDiff = await getDiff(octokit, repository, pull_request);
core.setOutput("numberOfFiles", parsedDiff.length);
const filesChanged = +core.getInput("filesChanged");
if (filesChanged && parsedDiff.length != filesChanged) {
core.setFailed(
"You should change exactly " + filesChanged + " file(s)"
Expand Down Expand Up @@ -127,7 +128,6 @@ async function run() {
}

core.info("Checking lines/files changed");
const linesChanged = +core.getInput("linesChanged");
if (linesChanged && additions != linesChanged) {
const this_msg =
"You should change exactly " +
Expand Down

0 comments on commit d1c81da

Please sign in to comment.