Skip to content

Commit

Permalink
Refactor updateforesttags to use functions (#358)
Browse files Browse the repository at this point in the history
* Skip 8u152+b16 as it's being a PITA
  • Loading branch information
karianna authored and johnoliver committed Sep 12, 2018
1 parent 2798a6e commit 363d56d
Show file tree
Hide file tree
Showing 13 changed files with 582 additions and 519 deletions.
67 changes: 0 additions & 67 deletions git-hg/add-branch-without-modules.sh

This file was deleted.

81 changes: 0 additions & 81 deletions git-hg/add-branch.sh

This file was deleted.

89 changes: 62 additions & 27 deletions git-hg/diff-without-getsource.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,42 +13,77 @@
# limitations under the License.
#

################################################################################
# diff-without-getsource
#
# For finding the diff between an AdoptOpenJDK Git repo and the OpenJDK Mercurial
# Repo for Java versions >= jdk10
#
# 1. Clones the AdoptOpenJDK Git repo for a particular version
# 2. Clones the OpenJDK Mercurial repo for that same version
# 3. Runs a diff between the two
#
################################################################################

set -euo pipefail

function checkArgs() {
if [ $# -lt 2 ]; then
echo Usage: "$0" '[AdoptOpenJDK Git Repo Version] [OpenJDK Mercurial Root Forest] [OpenJDK Mercurial Version]'
echo ""
echo "e.g. ./diff-without-getsource.sh jdk10u jdk-updates jdk10u"
echo ""
exit 1
fi
}

checkArgs $@

git_repo_version=$1
hg_root_forest=${2:-${1}} # for backwards compatibility
hg_repo_version=${3:-${hg_root_forest}} # for backwards compatibility
hg_root_forest=$2
hg_repo_version=$3

function cleanUp() {
rm -rf openjdk-git openjdk-hg
}

#cleanup
rm -rf openjdk-git openjdk-hg
function cloneRepos() {
echo "AdoptOpenJDK Git Repo Version: ${git_repo_version}"
echo "OpenJDK Mercurial Repo Version: ${hg_root_forest}/${hg_repo_version}"

echo "git repo version: ${git_repo_version}"
echo "hg repo version: ${hg_root_forest}/${hg_repo_version}"
git clone -b master "https://github.com/AdoptOpenJDK/openjdk-${git_repo_version}.git" openjdk-git || exit 1
hg clone "http://hg.openjdk.java.net/${hg_root_forest}/${hg_repo_version}" openjdk-hg || exit 1
}

git clone -b master "https://github.com/AdoptOpenJDK/openjdk-${git_repo_version}.git" openjdk-git || exit 1
hg clone "http://hg.openjdk.java.net/${hg_root_forest}/${hg_repo_version}" openjdk-hg || exit 1
function runDiff() {
diffNum=$(diff -rq openjdk-git openjdk-hg -x '.git' -x '.hg' -x '.hgtags' | wc -l)

diffNum=$(diff -rq openjdk-git openjdk-hg -x '.git' -x '.hg' -x '.hgtags' | wc -l)
if [ "$diffNum" -gt 0 ]; then
echo "ERROR - THE DIFF HAS DETECTED UNKNOWN FILES"
diff -rq openjdk-git openjdk-hg -x '.git' -x '.hg' -x '.hgtags' | grep 'only in' || exit 1
exit 1
fi
}

if [ "$diffNum" -gt 0 ]; then
echo "ERROR - THE DIFF HAS DETECTED UNKNOWN FILES"
diff -rq openjdk-git openjdk-hg -x '.git' -x '.hg' -x '.hgtags' | grep 'only in' || exit 1
exit 1
fi
function checkTags() {

# get latest git tag
cd openjdk-git || exit 1
gitTag=$(git describe --tags "$(git rev-list --tags --max-count=1)") || exit 1
cd - || exit 1

cd openjdk-git || exit 1
gitTag=$(git describe --tags "$(git rev-list --tags --max-count=1)") || exit 1
cd - || exit 1
cd openjdk-hg || exit 1
hgTag=$(hg log -r "." --template "{latesttag}\n") || exit 1
cd - || exit 1

cd openjdk-hg || exit 1
hgTag=$(hg log -r "." --template "{latesttag}\n") || exit 1
cd - || exit 1
if [ "$gitTag" == "$hgTag" ]; then
echo "Tags are in sync"
else
echo "ERROR - THE TAGS ARE NOT IN SYNC"
exit 1
fi
}

if [ "$gitTag" == "$hgTag" ]; then
echo "Tags are in sync"
else
echo "ERROR - THE TAGS ARE NOT IN SYNC"
exit 1
fi
cleanUp
cloneRepos
runDiff
checkTags
105 changes: 76 additions & 29 deletions git-hg/diff.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,46 +13,93 @@
# limitations under the License.
#

set -euo pipefail
################################################################################
# diff
#
# For finding the diff between an AdoptOpenJDK Git repo and the OpenJDK Mercurial
# Repo for Java versions <= jdk9u
#
# 1. Clones the AdoptOpenJDK Git repo for a particular version
# 2. Clones the OpenJDK Mercurial repo for that same version
# 3. Runs a diff between the two
#
################################################################################

set -euo

function checkArgs() {
if [ $# -lt 2 ]; then
echo Usage: "$0" '[AdoptOpenJDK Git Repo Version] [OpenJDK Mercurial Root Forest Version]'
echo ""
echo "e.g. ./diff.sh jdk8u jdk8u jdk8u or ./diff.sh jdk9u jdk-updates jdk9u"
echo ""
exit 1
fi
}

checkArgs $@

git_repo_version=$1
hg_root_forest=${2:-${1}} # for backwards compatibility
hg_repo_version=${3:-${hg_root_forest}} # for backwards compatibility

#cleanup
rm -rf openjdk-git openjdk-hg
function cleanUp() {
rm -rf openjdk-git openjdk-hg
}

function cloneRepos() {
echo "AdoptOpenJDK Git Repo Version: ${git_repo_version}"
echo "OpenJDK Mercurial Repo Version: ${hg_root_forest}/${hg_repo_version}"

git clone -b master "https://github.com/AdoptOpenJDK/openjdk-${git_repo_version}.git" openjdk-git || exit 1
hg clone "http://hg.openjdk.java.net/${hg_root_forest}/${hg_repo_version}" openjdk-hg || exit 1
}

function updateMercurialClone() {
cd openjdk-hg || exit 1

echo "git repo version: ${git_repo_version}"
echo "hg repo version: ${hg_root_forest}/${hg_repo_version}"
chmod u+x get_source.sh
./get_source.sh

git clone -b master "https://github.com/AdoptOpenJDK/openjdk-${git_repo_version}.git" openjdk-git || exit 1
hg clone "http://hg.openjdk.java.net/${hg_root_forest}/${hg_repo_version}" openjdk-hg || exit 1
cd - || exit 1
}

cd openjdk-hg || exit 1
bash get_source.sh
cd - || exit 1
function runDiff() {
diffNum=$(diff -rq openjdk-git openjdk-hg -x '.git' -x '.hg' -x '.hgtags' -x '.hgignore' -x 'get_source.sh' -x 'README.md' | wc -l)

diffNum=$(diff -rq openjdk-git openjdk-hg -x '.git' -x '.hg' -x '.hgtags' | wc -l)
if [ "$diffNum" -gt 0 ]; then
echo "ERROR - THE DIFF HAS DETECTED UNKNOWN FILES"
diff -rq openjdk-git openjdk-hg -x '.git' -x '.hg' -x '.hgtags' -x '.hgignore' -x 'get_source.sh' -x 'README.md' | grep 'Only in' || exit 1
exit 1
fi
}

if [ "$diffNum" -gt 0 ]; then
echo "ERROR - THE DIFF HAS DETECTED UNKNOWN FILES"
diff -rq openjdk-git openjdk-hg -x '.git' -x '.hg' -x '.hgtags' | grep 'only in' || exit 1
exit 1
fi
# This function only checks the latest tag, a future enhancement could be to
# check all tags
function checkLatestTag() {

# get latest git tag
cd openjdk-git || exit 1
gitTag=$(git describe --abbrev=0 --tags) || exit 1
cd - || exit 1

cd openjdk-git || exit 1
gitTag=$(git describe --abbrev=0 --tags) || exit 1
cd - || exit 1
cd openjdk-hg || exit 1
hgTag=$(hg log -r "." --template "{latesttag}\n") || exit 1
cd - || exit 1

cd openjdk-hg || exit 1
hgTag=$(hg log -r "." --template "{latesttag}\n") || exit 1
cd - || exit 1
if [ "$gitTag" == "$hgTag" ]; then
echo "Latest Tags are in sync"
else
echo "ERROR - Git tag ${gitTag} is not equal to Hg tag ${hgTag}"
exit 1
fi
}

if [ "$gitTag" == "$hgTag" ]; then
echo "Tags are in sync"
else
echo "ERROR - THE TAGS ARE NOT IN SYNC"
exit 1
fi
cleanUp
cloneRepos
updateMercurialClone
runDiff
# No longer run the tag checking as we're only pulling in selective tags for
# AdoptOpenJDK. For others using this script (who are pulling in ALL of the
# tags) you may wish to reenable this function and even enhance it to compare
# all tags.
#checkLatestTag
Loading

0 comments on commit 363d56d

Please sign in to comment.