Skip to content
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

Repository.getFilesChanged(start, end) contains the empty path filename and breaks Actions paths filter #23919

Closed
ChristopherHX opened this issue Apr 4, 2023 · 0 comments · Fixed by #23920
Labels
Milestone

Comments

@ChristopherHX
Copy link
Contributor

ChristopherHX commented Apr 4, 2023

Description

I wondered why this Gitea Actions workflow is triggered while changing the workflow file

Enable Gitea Actions and add the following file
Add .github/workflows/main.yml

on:
  push:
    paths-ignore:
    - '**.yml'
jobs:
  _:
    runs-on: ubuntu-latest
    steps:
    - run: exit 0

I expect that the workflow doesn't trigger unless I add a file without .yml extension

Workaround exclude the empty filepath

on:
  push:
    paths-ignore:
    - ''
    - '**.yml'
jobs:
  _:
    runs-on: ubuntu-latest
    steps:
    - run: exit 0

I tracked the bug down to this function:

return strings.Split(string(stdout), "\n"), nil

Callstack

Based on comment in another very similar function (without this bug)

// Because Git will always emit filenames with a terminal NUL ignore the last entry in the split - which will always be empty.

the empty filepath should be removed by the function before returning the path.

Furthermore it looks like these functions are duplicated, one bugfree and the other not.

Gitea Version

1.19.0+53-gdff3ce089

Can you reproduce the bug on the Gitea demo site?

No

Log Gist

No response

Screenshots

No response

Git Version

2.17.1

Operating System

Linux

How are you running Gitea?

I just downloaded https://dl.gitea.com/gitea/1.19/gitea-1.19-linux-arm64.xz and enabled actions for testing purposes.

Database

SQLite

@lunny lunny added this to the 1.19.1 milestone Apr 4, 2023
lunny pushed a commit that referenced this issue Apr 7, 2023
…-ignore` filter (#23920)

Remove the misbehaving function and call
Repository.GetFilesChangedBetween instead.

Fixes #23919

---

~~_TODO_ test this~~ `Repository.getFilesChanged` seems to be only used
by Gitea Actions, but a similar function already exists

**Update** I tested this change and the issue is gone.
GiteaBot pushed a commit to GiteaBot/gitea that referenced this issue Apr 7, 2023
…-ignore` filter (go-gitea#23920)

Remove the misbehaving function and call
Repository.GetFilesChangedBetween instead.

Fixes go-gitea#23919

---

~~_TODO_ test this~~ `Repository.getFilesChanged` seems to be only used
by Gitea Actions, but a similar function already exists

**Update** I tested this change and the issue is gone.
lunny pushed a commit that referenced this issue Apr 8, 2023
…-ignore` filter (#23920) (#23969)

Backport #23920 by @ChristopherHX

Remove the misbehaving function and call
Repository.GetFilesChangedBetween instead.

Fixes #23919

---

~~_TODO_ test this~~ `Repository.getFilesChanged` seems to be only used
by Gitea Actions, but a similar function already exists

**Update** I tested this change and the issue is gone.

Co-authored-by: ChristopherHX <[email protected]>
@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 23, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants