Skip to content

Commit fa0008b

Browse files
fix: Re-enables copyright hook, updates GitHub Action to only run pre-commi… (#7699)
1 parent 8d8bd44 commit fa0008b

File tree

3 files changed

+19
-12
lines changed

3 files changed

+19
-12
lines changed

.github/workflows/pre-commit.yaml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
1+
# Copyright 2023-2024, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
22
#
33
# Redistribution and use in source and binary forms, with or without
44
# modification, are permitted provided that the following conditions
@@ -34,6 +34,12 @@ jobs:
3434
runs-on: ubuntu-22.04
3535
steps:
3636
- uses: actions/checkout@v3
37+
with:
38+
fetch-depth: 2
39+
- name: Get modified files
40+
id: modified-files
41+
run: echo "modified_files=$(git diff --name-only -r HEAD^1 HEAD | xargs)" >> $GITHUB_OUTPUT
3742
- uses: actions/setup-python@v3
3843
- uses: pre-commit/action@v3.0.0
39-
44+
with:
45+
extra_args: --files ${{ steps.modified-files.outputs.modified_files }}

.pre-commit-config.yaml

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -73,13 +73,12 @@ repos:
7373
- id: requirements-txt-fixer
7474
- id: trailing-whitespace
7575

76-
# FIXME: Only run on changed files when triggered by GitHub Actions
77-
#- repo: local
78-
# hooks:
79-
# - id: add-license
80-
# name: Add License
81-
# entry: python tools/add_copyright.py
82-
# language: python
83-
# stages: [pre-commit]
84-
# verbose: true
85-
# require_serial: true
76+
- repo: local
77+
hooks:
78+
- id: add-license
79+
name: Add License
80+
entry: python tools/add_copyright.py
81+
language: python
82+
stages: [pre-commit]
83+
verbose: true
84+
require_serial: true

tools/add_copyright.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,8 @@ def add_copyrights(paths):
259259

260260
# Don't automatically 'git add' changes for now, make it more clear which
261261
# files were changed and have ability to see 'git diff' on them.
262+
# Note that this means the hook will modify files and then cancel the commit, which you will then
263+
# have to manually make again.
262264
# subprocess.run(["git", "add"] + paths)
263265

264266
print(f"Processed copyright headers for {len(paths)} file(s).")

0 commit comments

Comments
 (0)