Skip to content

Commit bee7f45

Browse files
authored
chore: merge staging to main (#35)
* chore(deps): bump actions/checkout from 3.1.0 to 3.2.0 (#5) * chore(deps-dev): update packaging requirement (#6) * chore(deps): bump ossf/scorecard-action from 2.0.6 to 2.1.2 (#8) * chore(deps): bump github/codeql-action from 2.1.31 to 2.1.37 (#9) * chore(deps-dev): update pylint requirement (#11) * chore(deps-dev): update hypothesis requirement (#10) * chore(deps): bump actions/setup-python from 4.3.0 to 4.4.0 (#7) * chore(deps-dev): update pre-commit requirement (#12) * chore(deps): use the fix for GHSA-hcpj-qp55-gfph (#13) * chore(deps-dev): update sphinx requirement (#14) * chore(deps): enable Dependabot to check Go deps (#15) * chore: enable CodeQL for Go (#18) * chore: update the copyright header at a specific line (#17) Signed-off-by: behnazh-w <[email protected]> * build: add separate target to setup binaries (#20) * chore(deps-dev): update hypothesis requirement (#26) * chore(deps-dev): update packaging requirement (#25) * chore(deps-dev): update pylint requirement (#24) * chore(deps): bump actions/checkout from 3.2.0 to 3.3.0 (#23) * chore(deps): bump actions/upload-artifact from 3.1.1 to 3.1.2 (#22) * chore(deps): bump actions/download-artifact from 3.0.1 to 3.0.2 (#21) * chore(deps): fix the checkout action semantic version (#27) * chore(deps-dev): update hypothesis requirement (#32) * chore(deps): bump github/codeql-action from 2.1.37 to 2.1.39 (#31) * chore(deps): bump actions/setup-python from 4.4.0 to 4.5.0 (#30) * ci: remove CodeQL Python version from matrix (#36) Signed-off-by: behnazh-w <[email protected]>
1 parent 2f658bd commit bee7f45

9 files changed

+95
-54
lines changed

.github/dependabot.yaml

+16-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) 2022 - 2022, Oracle and/or its affiliates. All rights reserved.
1+
# Copyright (c) 2022 - 2023, Oracle and/or its affiliates. All rights reserved.
22
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/.
33

44
# This configuration file enables Dependabot version updates.
@@ -36,3 +36,18 @@ updates:
3636
# https://docs.github.com/en/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file#reviewers
3737
# reviewers:
3838
# -
39+
40+
- package-ecosystem: gomod
41+
directory: /
42+
schedule:
43+
interval: weekly
44+
commit-message:
45+
prefix: chore
46+
prefix-development: chore
47+
include: scope
48+
open-pull-requests-limit: 13
49+
target-branch: staging
50+
# Add additional reviewers for PRs opened by Dependabot. For more information, see:
51+
# https://docs.github.com/en/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file#reviewers
52+
# reviewers:
53+
# -

.github/workflows/_build.yaml

+3-3
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,12 @@ jobs:
5151
steps:
5252

5353
- name: Check out repository
54-
uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # v3.1.0
54+
uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
5555
with:
5656
fetch-depth: 0
5757

5858
- name: Set up Python
59-
uses: actions/setup-python@13ae5bb136fac2878aff31522b9efb785519f984 # v4.3.0
59+
uses: actions/setup-python@d27e3f3d7c64b4bbf8e4abfb9b63b83e846e0435 # v4.5.0
6060
with:
6161
python-version: ${{ matrix.python }}
6262

@@ -123,7 +123,7 @@ jobs:
123123
# Currently reusable workflows do not support setting strategy property from the caller workflow.
124124
- name: Upload the package artifact for debugging and release
125125
if: matrix.os == env.ARTIFACT_OS && matrix.python == env.ARTIFACT_PYTHON
126-
uses: actions/upload-artifact@83fd05a356d7e2593de66fc9913b3002723633cb # v3.1.1
126+
uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2
127127
with:
128128
name: artifact-${{ matrix.os }}-python-${{ matrix.python }}
129129
path: |

.github/workflows/codeql-analysis.yaml

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) 2022 - 2022, Oracle and/or its affiliates. All rights reserved.
1+
# Copyright (c) 2022 - 2023, Oracle and/or its affiliates. All rights reserved.
22
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/.
33

44
# Run CodeQL over the package. For more configuration options see codeql/codeql-config.yaml
@@ -17,6 +17,7 @@ on:
1717
# Avoid unnecessary scans of pull requests.
1818
paths:
1919
- '**/*.py'
20+
- '**/*.go'
2021
schedule:
2122
- cron: 20 15 * * 3
2223
permissions:
@@ -35,17 +36,16 @@ jobs:
3536
matrix:
3637
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
3738
# Learn more about CodeQL language support at https://git.io/codeql-language-support
38-
language: [python]
39-
python: ['3.11']
39+
language: [python, go]
4040
steps:
4141

4242
- name: Checkout repository
43-
uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # v3.1.0
43+
uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
4444

4545
- name: Set up Python ${{ matrix.python }}
46-
uses: actions/setup-python@13ae5bb136fac2878aff31522b9efb785519f984 # v4.3.0
46+
uses: actions/setup-python@d27e3f3d7c64b4bbf8e4abfb9b63b83e846e0435 # v4.5.0
4747
with:
48-
python-version: ${{ matrix.python }}
48+
python-version: '3.11'
4949

5050
# For more details see the comment in _build.yaml.
5151
- name: Create empty virtual environment for Actions
@@ -55,7 +55,7 @@ jobs:
5555

5656
# Initializes the CodeQL tools for scanning.
5757
- name: Initialize CodeQL
58-
uses: github/codeql-action/init@c3b6fce4ee2ca25bc1066aa3bf73962fda0e8898 # v2.1.31
58+
uses: github/codeql-action/init@a34ca99b4610d924e04c68db79e503e1f79f9f02 # v2.1.39
5959
with:
6060
languages: ${{ matrix.language }}
6161
config-file: .github/codeql/codeql-config.yaml
@@ -68,4 +68,4 @@ jobs:
6868
# queries: ./path/to/local/query, your-org/your-repo/queries@main
6969

7070
- name: Perform CodeQL Analysis
71-
uses: github/codeql-action/analyze@c3b6fce4ee2ca25bc1066aa3bf73962fda0e8898 # v2.1.31
71+
uses: github/codeql-action/analyze@a34ca99b4610d924e04c68db79e503e1f79f9f02 # v2.1.39

.github/workflows/pr-conventional-commits.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,12 @@ jobs:
2525
steps:
2626

2727
- name: Check out repository
28-
uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # v3.1.0
28+
uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
2929
with:
3030
fetch-depth: 0
3131

3232
- name: Set up Python
33-
uses: actions/setup-python@13ae5bb136fac2878aff31522b9efb785519f984 # v4.3.0
33+
uses: actions/setup-python@d27e3f3d7c64b4bbf8e4abfb9b63b83e846e0435 # v4.5.0
3434
with:
3535
python-version: '3.11'
3636

.github/workflows/release.yaml

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) 2022 - 2022, Oracle and/or its affiliates. All rights reserved.
1+
# Copyright (c) 2022 - 2023, Oracle and/or its affiliates. All rights reserved.
22
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/.
33

44
# We run checks on pushing to the specified branches.
@@ -38,13 +38,13 @@ jobs:
3838
steps:
3939

4040
- name: Check out repository
41-
uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # v3.1.0
41+
uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
4242
with:
4343
fetch-depth: 0
4444
token: ${{ secrets.REPO_ACCESS_TOKEN }}
4545

4646
- name: Set up Python
47-
uses: actions/setup-python@13ae5bb136fac2878aff31522b9efb785519f984 # v4.3.0
47+
uses: actions/setup-python@d27e3f3d7c64b4bbf8e4abfb9b63b83e846e0435 # v4.5.0
4848
with:
4949
python-version: '3.11'
5050

@@ -88,12 +88,12 @@ jobs:
8888
steps:
8989

9090
- name: Check out repository
91-
uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # v3.1.0
91+
uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
9292
with:
9393
fetch-depth: 0
9494

9595
- name: Download artifact
96-
uses: actions/download-artifact@9782bd6a9848b53b110e712e20e42d89988822b7 # v3.0.1
96+
uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a # v3.0.2
9797
with:
9898
name: ${{ env.ARTIFACT_NAME }}
9999
path: dist
@@ -110,7 +110,7 @@ jobs:
110110
111111
# Create the Release Notes using commitizen.
112112
- name: Set up Python
113-
uses: actions/setup-python@13ae5bb136fac2878aff31522b9efb785519f984 # v4.3.0
113+
uses: actions/setup-python@d27e3f3d7c64b4bbf8e4abfb9b63b83e846e0435 # v4.5.0
114114
with:
115115
python-version: '3.11'
116116

@@ -183,12 +183,12 @@ jobs:
183183
steps:
184184

185185
- name: Check out repository
186-
uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # v3.0.2
186+
uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
187187
with:
188188
fetch-depth: 0
189189

190190
- name: Download provenance
191-
uses: actions/download-artifact@9782bd6a9848b53b110e712e20e42d89988822b7 # v3.0.1
191+
uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a # v3.0.2
192192
with:
193193
name: ${{ needs.provenance.outputs.provenance-name }}
194194

.github/workflows/scorecards-analysis.yaml

+4-4
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,12 @@ jobs:
2929
steps:
3030

3131
- name: Check out repository
32-
uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # v3.1.0
32+
uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
3333
with:
3434
persist-credentials: false
3535

3636
- name: Run analysis
37-
uses: ossf/scorecard-action@99c53751e09b9529366343771cc321ec74e9bd3d # v2.0.6
37+
uses: ossf/scorecard-action@e38b1902ae4f44df626f11ba0734b14fb91f8f86 # v2.1.2
3838
with:
3939
results_file: results.sarif
4040
results_format: sarif
@@ -49,13 +49,13 @@ jobs:
4949

5050
# Upload the results as artifacts (optional).
5151
- name: Upload artifact
52-
uses: actions/upload-artifact@83fd05a356d7e2593de66fc9913b3002723633cb # v3.1.1
52+
uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2
5353
with:
5454
name: SARIF file
5555
path: results.sarif
5656

5757
# Upload the results to GitHub's code scanning dashboard.
5858
- name: Upload to code-scanning
59-
uses: github/codeql-action/upload-sarif@c3b6fce4ee2ca25bc1066aa3bf73962fda0e8898 # v2.1.31
59+
uses: github/codeql-action/upload-sarif@a34ca99b4610d924e04c68db79e503e1f79f9f02 # v2.1.39
6060
with:
6161
sarif_file: results.sarif

Makefile

+16-12
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) 2022 - 2022, Oracle and/or its affiliates. All rights reserved.
1+
# Copyright (c) 2022 - 2023, Oracle and/or its affiliates. All rights reserved.
22
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/.
33

44
# Use bash as the shell when executing a rule's recipe. For more details:
@@ -83,25 +83,27 @@ venv:
8383
# The _build.yaml GitHub Actions workflow expects dist directory to exist.
8484
# So we create the dist dir if it doesn't exist in the setup target.
8585
# See https://packaging.python.org/en/latest/tutorials/packaging-projects/#generating-distribution-archives.
86-
# We also install SLSA verifier, mvnw, cyclonedx-go, and compile the Go modules.
86+
# We also install cyclonedx-go to generate SBOM for Go, compile the Go modules,
87+
# install SLSA verifier binary, and download mvnw.
8788
.PHONY: setup
88-
setup: force-upgrade setup-go
89+
setup: force-upgrade setup-go setup-binaries
8990
pre-commit install
9091
mkdir -p dist
92+
go install github.com/CycloneDX/cyclonedx-gomod/cmd/[email protected]
93+
setup-go:
94+
go build -o $(MACARON_PATH)/bin/ $(MACARON_PATH)/golang/cmd/...
95+
setup-binaries: $(MACARON_PATH)/bin/slsa-verifier $(MACARON_PATH)/resources/mvnw
96+
$(MACARON_PATH)/bin/slsa-verifier:
9197
git clone --depth 1 https://github.com/slsa-framework/slsa-verifier.git -b v2.0.1
9298
cd slsa-verifier/cli/slsa-verifier && go build -o $(MACARON_PATH)/bin/
9399
cd $(MACARON_PATH) && rm -rf slsa-verifier
94-
go install github.com/CycloneDX/cyclonedx-gomod/cmd/[email protected]
95-
echo "GOPATH=$$GOPATH"
96-
ls $$HOME/go/bin
100+
$(MACARON_PATH)/resources/mvnw:
97101
cd resources \
98102
&& wget https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper-distribution/3.1.1/maven-wrapper-distribution-3.1.1-bin.zip \
99103
&& unzip -o maven-wrapper-distribution-3.1.1-bin.zip \
100104
&& rm -r maven-wrapper-distribution-3.1.1-bin.zip \
101105
&& echo -e "distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.6/apache-maven-3.8.6-bin.zip\nwrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.1/maven-wrapper-3.1.1.jar" > .mvn/wrapper/maven-wrapper.properties \
102106
&& cd $(MACARON_PATH)
103-
setup-go:
104-
go build -o $(MACARON_PATH)/bin/ $(MACARON_PATH)/golang/cmd/...
105107

106108
# Install or upgrade an existing virtual environment based on the
107109
# package dependencies declared in pyproject.toml and go.mod.
@@ -160,14 +162,12 @@ requirements.txt: pyproject.toml
160162
# editable mode (like the one in development here) because they may not have
161163
# a PyPI entry; also print out CVE description and potential fixes if audit
162164
# found an issue.
163-
# TODO: do not ignore GHSA-hcpj-qp55-gfph once the patch is out.
164-
# See: https://github.com/gitpython-developers/GitPython/issues/1515.
165165
.PHONY: audit
166166
audit:
167167
if ! $$(python -c "import pip_audit" &> /dev/null); then \
168168
echo "No package pip_audit installed, upgrade your environment!" && exit 1; \
169169
fi;
170-
python -m pip_audit --skip-editable --desc on --fix --dry-run --ignore-vuln GHSA-hcpj-qp55-gfph
170+
python -m pip_audit --skip-editable --desc on --fix --dry-run
171171

172172
# Run some or all checks over the package code base.
173173
.PHONY: check check-code check-bandit check-flake8 check-lint check-mypy check-go
@@ -260,7 +260,11 @@ clean: dist-clean bin-clean
260260
nuke-caches: clean
261261
find src/ -type d -name __pycache__ -exec rm -fr {} +
262262
find tests/ -type d -name __pycache__ -exec rm -fr {} +
263-
nuke: nuke-caches
263+
nuke-mvnw:
264+
cd $(MACARON_PATH)/resources \
265+
&& rm mvnw mvnw.cmd mvnwDebug mvnwDebug.cmd \
266+
&& cd $(MACARON_PATH)
267+
nuke: nuke-caches nuke-mvnw
264268
if [ ! -z "${VIRTUAL_ENV}" ]; then \
265269
echo "Please deactivate the virtual environment first!" && exit 1; \
266270
fi

pyproject.toml

+5-5
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ dependencies = [
2525
"requests >=2.28.0,<3.0.0",
2626
"pydriller >=2.0,<3.0.0",
2727
"yamale >=4.0.3,<5.0.0",
28-
"packaging >=21.3,<22.0.0",
28+
"packaging >=21.3,<24.0.0",
2929
"jinja2 >=3.1.2,<4.0.0"
3030
]
3131
keywords = []
@@ -64,21 +64,21 @@ dev = [
6464
# Exclude pip-audit v2.4.9 because it has a bug.
6565
# See https://github.com/pypa/pip-audit/commit/22d7e4c7f5acd20852c57b52b46e861a716ab09f.
6666
"pip-audit >=2.4.8,<3.0.0,!=2.4.9",
67-
"pylint >=2.9.3,<2.15.8",
67+
"pylint >=2.9.3,<2.15.11",
6868
"cyclonedx-bom >=3.5.0,<4.0.0",
6969
]
7070
docs = [
71-
"sphinx >=5.3.0,<6.0.0",
71+
"sphinx >=5.3.0,<7.0.0",
7272
"sphinx-autodoc-typehints >=1.19.4,<2.0.0",
7373
"sphinx-rtd-theme >=1.0.0,<2.0.0",
7474
"numpydoc >=1.5.0,<2.0.0",
7575
]
7676
hooks = [
77-
"pre-commit >=2.18.0,<=2.20.0",
77+
"pre-commit >=2.18.0,<2.22.0",
7878
]
7979
# Note that the `custom_exit_code` and `env` plugins may currently be unmaintained.
8080
test = [
81-
"hypothesis >=6.21.0,<6.58.2",
81+
"hypothesis >=6.21.0,<6.64.1",
8282
"pytest >=7.2.0,<8.0.0",
8383
"pytest-custom_exit_code >=0.3.0,<1.0.0",
8484
"pytest-cov >=4.0.0,<5.0.0",

scripts/dev_scripts/copyright-checker.sh

+33-11
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env bash
22

3-
# Copyright (c) 2022 - 2022, Oracle and/or its affiliates. All rights reserved.
3+
# Copyright (c) 2022 - 2023, Oracle and/or its affiliates. All rights reserved.
44
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/.
55

66
#
@@ -10,6 +10,7 @@
1010
files=$(git diff --cached --name-only)
1111
currentyear=$(date +"%Y")
1212
missing_copyright_files=()
13+
license_note="Licensed under the Universal Permissive License v 1.0 as shown at https:\/\/oss\.oracle\.com\/licenses\/upl\/\."
1314

1415

1516
for f in $files; do
@@ -21,33 +22,54 @@ for f in $files; do
2122
startyear=$currentyear
2223
fi
2324
if ! grep -i -e "Copyright (c) $startyear - $currentyear, Oracle and/or its affiliates. All rights reserved." "$f" 1>/dev/null;then
24-
if [[ $f =~ .*\.(js$|py$|java$|tf$|go$|sh$|dl$|yaml$) ]] || [[ "${f##*/}" = "Dockerfile" ]];then
25+
if [[ $f =~ .*\.(js$|py$|java$|tf$|go$|sh$|dl$|yaml$) ]] || [[ "${f##*/}" = "Dockerfile" ]] || [[ "${f##*/}" = "Makefile" ]];then
2526
missing_copyright_files+=("$f")
2627
fi
2728
fi
2829
done
2930

3031
if [ ${#missing_copyright_files[@]} -ne 0 ]; then
3132
for f in "${missing_copyright_files[@]}"; do
33+
34+
# Don't allow this script to run on itself.
35+
if [[ $0 == $f ]];then
36+
echo "Cannot run the $0 on itself. Please fix the headers in this file manually."
37+
exit 1
38+
fi
39+
missing_license_note=$(grep -i "$license_note" "$f")
3240
startyear=$(git log --format=%ad --date=format:%Y "$f" | tail -1)
3341
if [[ -z "${startyear// }" ]]; then
3442
startyear=$currentyear
3543
fi
3644
if [[ $f =~ .*\.(js$|java$|go$|dl$) ]]; then
3745
expected="\/\* Copyright \(c\) $startyear - $currentyear, Oracle and\/or its affiliates\. All rights reserved\. \*\/"
38-
expected="$expected\n\/\* Licensed under the Universal Permissive License v 1.0 as shown at https:\/\/oss\.oracle\.com\/licenses\/upl\/\. \*\/"
39-
elif [[ $f =~ .*\.(py$|tf$|sh$|yaml$) ]] || [[ "${f##*/}" = "Dockerfile" ]]; then
46+
if [ ${#missing_license_note} -eq 0 ]; then
47+
expected="$expected\n\/\* $license_note \*\/"
48+
fi
49+
elif [[ $f =~ .*\.(py$|tf$|sh$|yaml$) ]] || [[ "${f##*/}" = "Dockerfile" ]] || [[ "${f##*/}" = "Makefile" ]]; then
4050
expected="# Copyright \(c\) $startyear - $currentyear, Oracle and\/or its affiliates\. All rights reserved\."
41-
expected="$expected\n# Licensed under the Universal Permissive License v 1.0 as shown at https:\/\/oss\.oracle\.com\/licenses\/upl\/\."
42-
51+
if [ ${#missing_license_note} -eq 0 ]; then
52+
expected="$expected\n# $license_note"
53+
fi
4354
fi
4455

45-
if ! grep -i -e "Copyright (c) .* Oracle and/or its affiliates. All rights reserved" "$f" 1>/dev/null;then
46-
echo "Copyright header missing for $f"
47-
sed -i "1s/^/$expected\n\n/" "$f"
56+
# Find the first matching copyright line.
57+
line_number=$(grep -m 1 -n -i -e "Copyright (c) .* Oracle and/or its affiliates. All rights reserved" "$f" | cut -d : -f 1)
58+
if [[ -z "$line_number" ]]; then
59+
echo "Copyright header missing for $f."
60+
61+
# Check for executable scripts and don't replace the first line starting with shebang.
62+
shebang_line=$(grep -m 1 -n "#!" "$f")
63+
if [[ -z "$shebang_line" ]];then
64+
# If there is no shebang, insert at the first line.
65+
sed -i "1s/^/$expected\n\n/" "$f"
66+
else
67+
# If there is a shebang, append to the end of the line.
68+
sed -i "$(echo $shebang_line | cut -d : -f 1)""s/$/\n\n$expected/" "$f"
69+
fi
4870
else
49-
echo "Copyright header needs update for $f"
50-
sed -i "1s/^.*/$expected/" "$f"
71+
echo "Copyright header needs update for $f."
72+
sed -i "$line_number""s/^.*/$expected/" "$f"
5173
fi
5274
done
5375
echo "Copyright headers have been automatically added/updated. Please review and stage the changes before running git commit again."

0 commit comments

Comments
 (0)