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

[Feature] Get all changes on current branch against a base_sha #599

Closed
2 tasks done
boranliu opened this issue Aug 24, 2022 · 4 comments
Closed
2 tasks done

[Feature] Get all changes on current branch against a base_sha #599

boranliu opened this issue Aug 24, 2022 · 4 comments
Labels
enhancement New feature or request

Comments

@boranliu
Copy link

boranliu commented Aug 24, 2022

Is this feature missing in the latest version?

  • I'm using the latest release

Is your feature request related to a problem? Please describe.

Currently I am trying to get all the modified files from a PR when I push a single commit (with potentially multiple commits pushed earlier), and would like to see all modified files (including all modified files from previously pushed commits) against a different base_sha other than the last commit from the same remote branch.

This should be similar to since_last_remote_commit but with the ability to input a base_sha.

Use case for this will be something like branching out from a base branch and trying to check all modified files from the current branch to the base branch (with multiple commits pushed to a PR)

Describe the solution you'd like?

The ability to list all changed files in all commits in current branch that triggers the actions against another branch (base_sha)

Describe alternatives you've considered?

No response

Anything else?

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct
@boranliu boranliu added the enhancement New feature or request label Aug 24, 2022
@github-actions
Copy link
Contributor

Thanks for reporting this issue, don't forget to star this project to help us reach a wider audience.

@jackton1
Copy link
Member

jackton1 commented Aug 25, 2022

@boranliu By default using

on:
  pull_request:
    branches:
      - '**'

jobs:
  build:
    runs-on: ubuntu-latest
    name: Test changed-files
    steps:
      - uses: actions/checkout@v3
        with:
          fetch-depth: 0

      - name: Get changed files
        id: changed-files
        uses: tj-actions/changed-files@v29.0.0

      - name: List all changed files
        run: |
          for file in ${{ steps.changed-files.outputs.all_changed_files }}; do
            echo "$file was changed"
          done

The diff is based on the last commit SHA on the Target branch of the pull request and the current pushed commit SHA of the current branch

Can you elaborate on the difference in your use case?

@boranliu
Copy link
Author

@boranliu By default using

on:
  pull_request:
    branches:
      - '**'

jobs:
  build:
    runs-on: ubuntu-latest
    name: Test changed-files
    steps:
      - uses: actions/checkout@v3
        with:
          fetch-depth: 0

      - name: Get changed files
        id: changed-files
        uses: tj-actions/changed-files@v29.0.0

      - name: List all changed files
        run: |
          for file in ${{ steps.changed-files.outputs.all_changed_files }}; do
            echo "$file was changed"
          done

The diff is based on the last commit SHA on the Target branch of the pull request and the current pushed commit SHA of the current branch

Can you elaborate on the difference in your use case?

Thanks for the quick response.

My use case is for on push event and one example can be illustrated as below:

  • Create a branch B which is branched off branch A
  • PR on branch B
  • Push several commits (in individual commands, so multiple pushes) to branch B
  • Lets assume the last commit on branch A has sha 123

So I would like to get all changes files on the current branch B against branch A (essentially sha 123) for every new push (which means that not only from the current commit that I pushed, but all the commits pushed earlier). Right now the behavior I spotted is that diff is only calculated between each new commit I pushed on branch B and the commit with sha 123 (from branch A).

One example could be:
On branch B:

  • Push a commit with file1.txt changed
  • Push another commit with file2.txt changed

Now the expected behavior I am trying to achieve is that for the second commit, all_modified_files should return both file1.txt and file2.txt

@jackton1
Copy link
Member

jackton1 commented Aug 26, 2022

@boranliu In that case I'll suggest using

      - name: Get changed files
        id: changed-files
        uses: tj-actions/changed-files@v29.0.1
        with:
          base_sha: ${{ github.event.pull_request.base.sha }}

See: https://github.com/tj-actions/changed-files for more examples you can also take a look at fork-point. Also, note that the event needs to be a pull_request event that gets triggered when new commits are pushed to B.

@jackton1 jackton1 closed this as not planned Won't fix, can't repro, duplicate, stale Aug 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants