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 request for retrieve multiple branches tips with --depth 1 #329

Open
askoriy opened this issue Aug 13, 2020 · 4 comments
Open

Feature request for retrieve multiple branches tips with --depth 1 #329

askoriy opened this issue Aug 13, 2020 · 4 comments

Comments

@askoriy
Copy link

askoriy commented Aug 13, 2020

I need to checkout developing branch and then compare changes with the master branch.
By default actions/checkout@v2 fetches only one branch, and the only option to fetch multiple branches is to use fetch-depth: '0', which retrieves all history for all branches and tags, wasting time and traffic.

With git my issue is solving as clone --depth 1 --no-single-branch --branch developing <uri>
So next pipeline can operate with git diff origin/master

Is there a way to retrieve all (or some) branch tips without retrieving the whole history with this GHA?

@ericsciple
Copy link
Contributor

The token is persisted by default, so I think this will work:

steps:
  - uses: actions/checkout@v2
  - run: git fetch --depth=1

Hope that helps, let me know.

@Gowee
Copy link

Gowee commented Oct 27, 2020

I am encountering a similar problem. I am not sure how to apply the solution by eric.
So after some searching, here is my solution adapted from https://stackoverflow.com/a/27393574/5488616 :

git remote set-branches origin '*'
git fetch --depth 1
git checkout SOME_OTHER_BRANCH

@wmertens
Copy link

wmertens commented Jul 9, 2021

I'd just like to report that the @ericsciple's workaround works fine, and it allowed me to do eslint and jest only against changed files 🎉

eslint: git diff --name-only --diff-filter=ACMRTUXB origin/$BASE_REF | grep -E ".[jt]sx?$" | xargs -d \\\\n eslint --format github

jest: git reset origin/$BASE_REF; NODE_ENV=test jest --ci --coverage --color --onlyChanged; out=$?; git reset HEAD@{1}; exit $out

BASE_REF is passed in env, github.base_ref

@ioquatix
Copy link

ioquatix commented Jul 26, 2023

I'm also interested in this, but for computing coverage.

To compute coverage of a PR, we need to detect modified lines relative to the default branch (e.g. main). This is so we can correctly compute a diff.

So, I need to fetch both the PR's branch, and the default branch, but I don't need all the commits, IIUC.

Maybe having an option like additional-refs is sufficient.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants