Skip to content

Commit

Permalink
Merge pull request openshift#315 from danwinship/sync-rebuild
Browse files Browse the repository at this point in the history
Force a rebuild after ./hack/sync-to-origin.sh
  • Loading branch information
Ravi Sankar Penta committed May 31, 2016
2 parents 4c84f6e + 2014896 commit 0dc6df5
Showing 1 changed file with 27 additions and 10 deletions.
37 changes: 27 additions & 10 deletions hack/sync-to-origin.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,22 +35,32 @@ validate_args() {
sdn_repo_dir=$(readlink -f -- $sdn_repo_dir)
}

handle_uncommited_sdn_changes() {
has_uncommitted_sdn_changes() {
dir=$1
ret=1
if [ -d "$dir" ]; then
pushd $origin_repo_dir >/dev/null
if (git diff $dir 2>/dev/null | grep -q '+++ ') || \
(git diff $dir --cached 2>/dev/null | grep -q '+++ '); then
echo "Warning: openshift origin repo has uncommited sdn changes under '$dir'"
echo -n "Continue to override the changes?[y/n]: "
read input
input=$(echo $input | tr '[:upper:]' '[:lower:]')
if [ "$input" != "y" ] && [ "$input" != "yes" ]; then
exit 0
fi
ret=0
fi
popd >/dev/null
fi

return $ret
}

handle_uncommitted_sdn_changes() {
dir=$1
if has_uncommitted_sdn_changes $dir; then
echo "Warning: openshift origin repo has uncommitted sdn changes under '$dir'"
echo -n "Continue to override the changes?[y/n]: "
read input
input=$(echo $input | tr '[:upper:]' '[:lower:]')
if [ "$input" != "y" ] && [ "$input" != "yes" ]; then
exit 0
fi
fi
}

copy_files_to_origin() {
Expand All @@ -65,8 +75,8 @@ copy_files_to_origin() {
echo "Warning: openshift origin repo doesn't contain sdn dirs under '$origin_sdn_pkg_dir'"
fi

# If any uncommited sdn changes found in origin repo, get user input before proceeding further
handle_uncommited_sdn_changes $origin_sdn_pkg_dir
# If any uncommitted sdn changes found in origin repo, get user input before proceeding further
handle_uncommitted_sdn_changes $origin_sdn_pkg_dir

# Move old origin sdn changes to temporary sync dir
mv -f $origin_sdn_pkg_dir $temp_sync_dir
Expand All @@ -75,6 +85,13 @@ copy_files_to_origin() {

# Copy new sdn changes to origin repo
cp -rf $sdn_pkg_dir $sdn_plugins_dir $origin_sdn_pkg_dir

# Clean old builds so a "make" will rebuild them
if has_uncommitted_sdn_changes $origin_sdn_pkg_dir; then
for dir in $origin_repo_dir/Godeps/_workspace/pkg/*/github.com/openshift/openshift-sdn; do
find $dir -name '*.a' -print0 | xargs -0 rm -f
done
fi
}

update_origin_godeps() {
Expand Down

0 comments on commit 0dc6df5

Please sign in to comment.