-
-
Notifications
You must be signed in to change notification settings - Fork 714
Improvements to the configuration logic #744
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
Changes from all commits
d5b01d6
a138c65
5478e65
24f125d
773bffa
c95017a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,6 @@ | ||
| # ScanCode special files | ||
| /SCANCODE_DEV_MODE | ||
| /SCANCODE_GIT_MODE | ||
|
|
||
| # Python compiled files | ||
| *.py[cod] | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -105,10 +105,33 @@ _canonicalize_file_path() { | |
| SCANCODE_BIN="$( realpath "${BASH_SOURCE[0]}" )" | ||
| SCANCODE_ROOT_DIR="$( cd "$( dirname "${SCANCODE_BIN}" )" && pwd )" | ||
|
|
||
| SCANCODE_CONFIG_DIR="etc/conf" | ||
|
|
||
| GIT_STATUS=$(git -C "$SCANCODE_ROOT_DIR" status --porcelain 2> /dev/null) | ||
| if [ $? -eq 0 ]; then | ||
| # This is a Git working tree, check whether it is clean. | ||
| if [ -z "$GIT_STATUS" ]; then | ||
| # This is a clean working tree, check whether configure has been run | ||
| # before for this commit. | ||
| GIT_COMMIT_CONFIGURED=$(cat "$SCANCODE_ROOT_DIR/SCANCODE_GIT_MODE" 2> /dev/null) | ||
| GIT_COMMIT_HEAD=$(git -C "$SCANCODE_ROOT_DIR" rev-parse HEAD) | ||
| if [ "$GIT_COMMIT_CONFIGURED" != "$GIT_COMMIT_HEAD" ]; then | ||
| echo "* (Re-)Configuring ScanCode because Git commits have changed..." | ||
| CONFIGURE_QUIET=1 $SCANCODE_ROOT_DIR/configure $SCANCODE_CONFIG_DIR | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. IMHO to be really safe, you should first issue a
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. FWIW, I tried to avoid a full clean by doing e.g. 773bffa. |
||
| fi | ||
| echo $GIT_COMMIT_HEAD > "$SCANCODE_ROOT_DIR/SCANCODE_GIT_MODE" | ||
| else | ||
| echo "* (Re-)Configuring ScanCode because Git working tree is not clean..." | ||
| CONFIGURE_QUIET=1 $SCANCODE_ROOT_DIR/configure $SCANCODE_CONFIG_DIR | ||
| fi | ||
| else | ||
| rm -f "$SCANCODE_ROOT_DIR/SCANCODE_GIT_MODE" | ||
| fi | ||
|
|
||
| SCANCODE_CONFIGURED_PYTHON=$SCANCODE_ROOT_DIR/bin/python | ||
| if [ ! -f "$SCANCODE_CONFIGURED_PYTHON" ]; then | ||
| echo "* Configuring ScanCode for first use..." | ||
| CONFIGURE_QUIET=1 $SCANCODE_ROOT_DIR/configure etc/conf | ||
| CONFIGURE_QUIET=1 $SCANCODE_ROOT_DIR/configure $SCANCODE_CONFIG_DIR | ||
| fi | ||
|
|
||
| $SCANCODE_ROOT_DIR/bin/scancode "$@" | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this also implicitly checks for Git being available locally? Just curious what the different with a plain
git status?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Exactly. It implicitly checks for
$SCANCODE_ROOT_DIRto be a Git working tree (git statusreturns code 128 otherwise), and also for thegitexecutable to be present (in this case it's Bash that returns code 127).