Skip to content

Update no-nexus.sh script to use gsed #12

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

Merged
merged 2 commits into from
Jun 16, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions .githooks/no-nexus.sh

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

similar to my comment on the other PR, could you add a comment section explaining what this githook is needed for and what it does

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added now:

# This script ensures that the poetry.lock file does not contain references to the internal Indeed Nexus PyPI repository.
# It is used as a git hook to automatically remove the [package.source] section for Nexus from poetry.lock.
# This is necessary to ensure the lock file is portable and open-source friendly.
# The script uses gsed to remove the Nexus source block and any resulting empty lines, then checks if any changes were made.
# 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.

Original file line number Diff line number Diff line change
@@ -1,16 +1,22 @@
#! /usr/bin/env bash

sed -i'' \
# This script ensures that the poetry.lock file does not contain references to the internal Indeed Nexus PyPI repository.
# It is used as a git hook to automatically remove the [package.source] section for Nexus from poetry.lock.
# This is necessary to ensure the lock file is portable and open-source friendly.
# The script uses gsed to remove the Nexus source block and any resulting empty lines, then checks if any changes were made.
# 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.

gsed -i'' \
-e '/./{H;$!d}' \
-e 'x' \
-e 's|\[package.source\]\ntype\s*=\s*\"legacy\"\nurl\s*=\s*\"https://nexus.corp.indeed.com/repository/pypi/simple\"\nreference\s*=\s*\"nexus\"||' \
poetry.lock

sed -i'' \
gsed -i'' \
-e '1{/^\s*$/d}' \
poetry.lock

sed -i'' \
gsed -i'' \
-e '/^\s*$/N;/^\s*\n$/D' \
poetry.lock

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

exit 1