Skip to content
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

fix error handling and return code #35017

Closed
Closed
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
22 changes: 12 additions & 10 deletions pkgs/build-support/fetchgit/nix-prefetch-git
Original file line number Diff line number Diff line change
Expand Up @@ -208,11 +208,12 @@ clone(){
init_remote "$url"

# Download data from the repository.
checkout_ref "$hash" "$ref" ||
checkout_hash "$hash" "$ref" || (
echo 1>&2 "Unable to checkout $hash$ref from $url."
exit 1
)
exit_status=$(checkout_ref "$hash" "$ref" || checkout_hash "$hash" "$ref")
Copy link
Member Author

Choose a reason for hiding this comment

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

i'm not sure if this is the proper solution but it seems to work. can someone confirm this is correct code?


if [ $exit_status ]; then
echo 1>&2 "Unable to checkout $hash$ref from $url."
exit 1
fi

# Checkout linked sources.
if test -n "$fetchSubmodules"; then
Expand Down Expand Up @@ -314,11 +315,12 @@ clone_user_rev() {
errfile="$(mktemp "${TMPDIR:-/tmp}/git-checkout-err-XXXXXXXX")"
# shellcheck disable=SC2064
trap "rm -rf \"$errfile\"" EXIT
_clone_user_rev "$@" 2> "$errfile" || (
status="$?"
cat "$errfile" >&2
exit "$status"
)
_clone_user_rev "$@" 2> "$errfile"
status=$?
if [ $status -ne 0 ]; then
cat "$errfile" >&2
exit $status
fi
fi
}

Expand Down