ci: Fix get_changed_files_output (#5944)

* ci: Fix get_changed_files_output

* Update project_tests.yml

* ci: Fix presubmit checks

* ci: Use fetch-depth:0 instead of --unshallow
This commit is contained in:
MarcoFalke 2021-06-21 14:14:41 +00:00 committed by GitHub
parent f43633e0ec
commit aed20a9b62
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 11 additions and 8 deletions

View File

@ -15,8 +15,9 @@ jobs:
access_token: ${{ github.token }}
- uses: actions/checkout@v2
- run: | # Needed for git diff to work.
git fetch origin master --depth 1
with: # Needed for git diff to work. (get_changed_files)
fetch-depth: 0
- run: |
git symbolic-ref refs/remotes/origin/HEAD refs/remotes/origin/master
- name: Setup python environment

View File

@ -16,8 +16,9 @@ jobs:
access_token: ${{ github.token }}
- uses: actions/checkout@v2
- run: | # Needed for git diff to work.
git fetch origin master --depth 1
with: # Needed for git diff to work. (get_changed_files)
fetch-depth: 0
- run: |
git symbolic-ref refs/remotes/origin/HEAD refs/remotes/origin/master
- name: Setup python environment

View File

@ -48,8 +48,9 @@ jobs:
access_token: ${{ github.token }}
- uses: actions/checkout@v2
- run: | # Needed for git diff to work.
git fetch origin master --depth 1
with: # Needed for git diff to work. (get_changed_files)
fetch-depth: 0
- run: |
git symbolic-ref refs/remotes/origin/HEAD refs/remotes/origin/master
- name: Clear unnecessary files

View File

@ -38,7 +38,7 @@ LANGUAGES_WITH_COVERAGE_SUPPORT = ['c', 'c++', 'go', 'jvm', 'rust']
def get_changed_files_output():
"""Returns the output of a git command that discovers changed files."""
branch_commit_hash = subprocess.check_output(
['git', 'merge-base', 'FETCH_HEAD', 'origin/HEAD']).strip().decode()
['git', 'merge-base', 'HEAD', 'origin/HEAD']).strip().decode()
return subprocess.check_output(
['git', 'diff', '--name-only', branch_commit_hash + '..']).decode()

View File

@ -346,7 +346,7 @@ def yapf(paths, validate=True):
def get_changed_files():
"""Return a list of absolute paths of files changed in this git branch."""
branch_commit_hash = subprocess.check_output(
['git', 'merge-base', 'FETCH_HEAD', 'origin/HEAD']).strip().decode()
['git', 'merge-base', 'HEAD', 'origin/HEAD']).strip().decode()
diff_commands = [
# Return list of modified files in the commits on this branch.