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

Reproducible fix #7977

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: 13 additions & 9 deletions src/sonic-build-hooks/hooks/git
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ parse_config(){

MODE_CLONE=0
# parse input parameters
for i in "$@"
for para in "$@"
do
if [[ $i == "clone" ]];then
if [[ $para == "clone" ]];then
MODE_CLONE=1
fi
done
Expand Down Expand Up @@ -39,7 +39,7 @@ get_clone_path(){
done

# if not specific clone path, get default clone path
[ -z $clone_PATH ] && clone_PATH=`echo $URL | rev | awk -F/ '{print$1}' | rev | awk -F. '{print$1}'`
[ -z $clone_PATH ] && clone_PATH=`echo $URL | awk -F/ '{print$NF}' | awk -F. '{print$1}'`
}

main(){
Expand All @@ -56,17 +56,21 @@ main(){

get_clone_path "$@"
pushd $clone_PATH &> /dev/null
commit_latest=`$REAL_COMMAND log -n 1 | head -n 1| awk '{print$2}'`
commit_latest=`$REAL_COMMAND rev-parse HEAD`
[ -f $version_file ] && commit=`grep $URL $version_file | awk -F, '{print$2}'`

# record version file
echo "$URL==$commit_latest" >> $new_version_file
sort $new_version_file -o $new_version_file -u &> /dev/null

# control version or record version file
if [[ $ENABLE_VERSION_CONTROL_GIT == "y" ]];then
# control version
[ ! -z $commit ] && $REAL_COMMAND reset --hard $commit &> /dev/null
else
# record version file
echo "$URL==$commit_latest" >> $new_version_file
sort $new_version_file -o $new_version_file -u &> /dev/null
if [ -z $commit ]; then
echo "Failed to verify the package: $URL, the version is not specified."
exit 1
fi
$REAL_COMMAND reset --hard $commit &> /dev/null
fi
popd &> /dev/null

Expand Down