From 25770debabd252becf787048c1d9f5069825559f Mon Sep 17 00:00:00 2001 From: LuisLiraC Date: Sat, 14 Sep 2024 09:08:53 -0600 Subject: [PATCH 1/4] allow multiline patterns --- README.md | 13 ++++++++++++- action.yaml | 7 ++++--- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 198d3b6..40a845a 100644 --- a/README.md +++ b/README.md @@ -18,6 +18,17 @@ Examples: - `src/**/*`: All files within the `src` directory and its subdirectories - `!README.md`: Exclude the README.md file +Patterns could be a single line or multiline string. +```yaml +patterns: | + *.rs + src/**/* + !README.md +``` +```yaml +patterns: '*.rs,src/**/*,!README.md' +``` + ## Outputs ### `DIFF_FILES` @@ -56,4 +67,4 @@ jobs: ``` > [!WARNING] -> At this moment it only works with the `pull_request` event. It uses the `GITHUB_BASE_REF` environment variable to get the base branch of the PR and this environment variable is only available in the `pull_request` event. +> At this moment it only works with the `pull_request` event. It uses the `GITHUB_BASE_REF` environment variable to get the base branch of the PR and this it is only available in the `pull_request` event. diff --git a/action.yaml b/action.yaml index 95e4b1e..a51a13f 100644 --- a/action.yaml +++ b/action.yaml @@ -18,8 +18,7 @@ runs: shell: bash run: | BIN_URL=$(curl https://api.github.com/repos/LuisLiraC/git-diff/releases/latest | jq -r '.assets[0].browser_download_url') - echo "Downloading from $BIN_URL" - curl -L $BIN_URL -o rust-binary.tgz + curl -s -L $BIN_URL -o rust-binary.tgz tar -xzvf rust-binary.tgz mv ./Linux/git-diff ./git-diff @@ -27,4 +26,6 @@ runs: id: get-git-diff shell: bash run: | - ./git-diff --patterns='${{ inputs.patterns }}' + PATTERNS="${{ inputs.patterns }}" + COMMA_SEPARATED_PATTERNS=$(echo "$PATTERNS" | tr '\n' ',' | sed -e 's/,$//' | sed 's/,$//' | sed 's/ //g') + ./git-diff --patterns='$COMMA_SEPARATED_PATTERNS' From 4683a901273adde9eb6e4262791c77ea4f803cce Mon Sep 17 00:00:00 2001 From: LuisLiraC Date: Sat, 14 Sep 2024 09:17:00 -0600 Subject: [PATCH 2/4] echo patterns before diff --- action.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/action.yaml b/action.yaml index a51a13f..280d87a 100644 --- a/action.yaml +++ b/action.yaml @@ -28,4 +28,5 @@ runs: run: | PATTERNS="${{ inputs.patterns }}" COMMA_SEPARATED_PATTERNS=$(echo "$PATTERNS" | tr '\n' ',' | sed -e 's/,$//' | sed 's/,$//' | sed 's/ //g') + echo "Patterns: $COMMA_SEPARATED_PATTERNS" ./git-diff --patterns='$COMMA_SEPARATED_PATTERNS' From 04a1b1a26220f760529187724e806fcd943c1445 Mon Sep 17 00:00:00 2001 From: LuisLiraC Date: Sat, 14 Sep 2024 09:36:22 -0600 Subject: [PATCH 3/4] remove print patterns --- action.yaml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/action.yaml b/action.yaml index 280d87a..d39b9d5 100644 --- a/action.yaml +++ b/action.yaml @@ -28,5 +28,4 @@ runs: run: | PATTERNS="${{ inputs.patterns }}" COMMA_SEPARATED_PATTERNS=$(echo "$PATTERNS" | tr '\n' ',' | sed -e 's/,$//' | sed 's/,$//' | sed 's/ //g') - echo "Patterns: $COMMA_SEPARATED_PATTERNS" - ./git-diff --patterns='$COMMA_SEPARATED_PATTERNS' + ./git-diff --patterns=$COMMA_SEPARATED_PATTERNS From 31010073742fee059352341fe2fa9a4f7b4ff2ed Mon Sep 17 00:00:00 2001 From: LuisLiraC Date: Sat, 14 Sep 2024 09:38:12 -0600 Subject: [PATCH 4/4] print patterns --- action.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/action.yaml b/action.yaml index d39b9d5..4241b17 100644 --- a/action.yaml +++ b/action.yaml @@ -28,4 +28,6 @@ runs: run: | PATTERNS="${{ inputs.patterns }}" COMMA_SEPARATED_PATTERNS=$(echo "$PATTERNS" | tr '\n' ',' | sed -e 's/,$//' | sed 's/,$//' | sed 's/ //g') + echo "Files patterns: $COMMA_SEPARATED_PATTERNS" + ./git-diff --patterns=$COMMA_SEPARATED_PATTERNS