Skip to content

Commit b7c3f01

Browse files
authored
Merge pull request #12 from indeedeng/jira/scacador/NOBUG
Update no-nexus.sh script to use `gsed`
2 parents 797925f + 2ca7183 commit b7c3f01

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

.githooks/no-nexus.sh

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,22 @@
11
#! /usr/bin/env bash
22

3-
sed -i'' \
3+
# This script ensures that the poetry.lock file does not contain references to the internal Indeed Nexus PyPI repository.
4+
# It is used as a git hook to automatically remove the [package.source] section for Nexus from poetry.lock.
5+
# This is necessary to ensure the lock file is portable and open-source friendly.
6+
# The script uses gsed to remove the Nexus source block and any resulting empty lines, then checks if any changes were made.
7+
# If Nexus references are found and removed, the script exits with 1 to prevent the commit, so we can stage the changes made by the script before committing again.
8+
9+
gsed -i'' \
410
-e '/./{H;$!d}' \
511
-e 'x' \
612
-e 's|\[package.source\]\ntype\s*=\s*\"legacy\"\nurl\s*=\s*\"https://nexus.corp.indeed.com/repository/pypi/simple\"\nreference\s*=\s*\"nexus\"||' \
713
poetry.lock
814

9-
sed -i'' \
15+
gsed -i'' \
1016
-e '1{/^\s*$/d}' \
1117
poetry.lock
1218

13-
sed -i'' \
19+
gsed -i'' \
1420
-e '/^\s*$/N;/^\s*\n$/D' \
1521
poetry.lock
1622

@@ -21,4 +27,3 @@ if [[ $CHANGES -eq 0 ]]; then
2127
fi
2228

2329
exit 1
24-

0 commit comments

Comments
 (0)