Skip to content

Commit

Permalink
Revert "Refactor updateforesttags to use functions (#358)" (#500)
Browse files Browse the repository at this point in the history
This reverts commit 363d56d.
  • Loading branch information
johnoliver authored and karianna committed Sep 12, 2018
1 parent 363d56d commit d03d9cf
Show file tree
Hide file tree
Showing 13 changed files with 519 additions and 582 deletions.
67 changes: 67 additions & 0 deletions git-hg/add-branch-without-modules.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
#!/bin/bash
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

################################################################################
# add-branch-without-modules
#
# Local setup of the Git clone branches for the OpenJDK10 (updates) mercurial
# repository
#
# Initial repo will be pushed to [email protected]:AdoptOpenJDK/openjdk-jdk10u.git
#
################################################################################

set -euo pipefail

echo "Import common functionality"
# shellcheck disable=SC1091
source import-common.sh

echo "Enter hg"
cd hg || exit 1

bpath=$1
branch=$2

echo "Create $bpath"
mkdir -p "$bpath" || exit 1

echo "git hg clone $bpath (root)"
git hg clone "http://hg.openjdk.java.net/$bpath" "$bpath/root" || exit 1

echo "checkout the $branch"
if [ "$branch" != "" ]; then
cd "$bpath/root" || exit 1
git-hg checkout "$branch" || exit 1
cd - || exit 1
fi

echo "Enter ../combined"
cd ../combined || exit 1

echo "checkout the master branch"
git checkout -b master || exit 1

echo "Add remote for (root)"
git remote add "imports/$bpath/root" "../hg/$bpath/root" || exit 1

echo "Fetch (root)"
git fetch "imports/$bpath/root" || exit 1

echo "Merge (root)"
git merge "imports/$bpath/root/master" -m "Initial merge of (root)" || exit 1

echo "Push the tags to the master branch"
git push github master --tags || exit 1
81 changes: 81 additions & 0 deletions git-hg/add-branch.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
#!/bin/bash
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

set -euo pipefail

echo "Common defs"

# shellcheck disable=SC1091
source import-common.sh

echo "Enter hg"

cd hg || exit 1

bpath=$1

echo "Create $bpath"

mkdir -p "$bpath" || exit 1

echo "Clone $bpath (root)"
git hg clone "http://hg.openjdk.java.net/$bpath" "$bpath/root" || exit 1

# shellcheck disable=SC2154
for module in "${modules[@]}"
do
echo "Clone $bpath -> $module"
git hg clone "http://hg.openjdk.java.net/$bpath/$module" "$bpath/$module" || exit 1
done

echo "Exit hg"
echo "Enter combined"

cd ../combined || exit 1

echo "Branch $bpath"

pwd

git checkout -b master || exit 1

echo "Add remote for (root)"

git remote add "imports/$bpath/root" "../hg/$bpath/root" || exit 1

echo "Fetch (root)"

git fetch "imports/$bpath/root" || exit 1

echo "Merge (root)"

git merge "imports/$bpath/root/master" -m "Initial merge of (root)" || exit 1

# shellcheck disable=SC2154
for module in "${modules[@]}"
do
echo "Add remote for '$module'"
git remote add "imports/$bpath/$module" "../hg/$bpath/$module" || exit 1

echo "Fetch '$module'"
git fetch "imports/$bpath/$module" || exit 1

echo "Merge '$module'"
git subtree add --prefix="$module" "imports/$bpath/$module/master" -m "Initial merge of '$module'" || exit 1
done

echo "Push"

git push github master --tags || exit 1
89 changes: 27 additions & 62 deletions git-hg/diff-without-getsource.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,77 +13,42 @@
# 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
hg_repo_version=$3

function cleanUp() {
rm -rf openjdk-git openjdk-hg
}
hg_root_forest=${2:-${1}} # for backwards compatibility
hg_repo_version=${3:-${hg_root_forest}} # for backwards compatibility

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

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
}
echo "git repo version: ${git_repo_version}"
echo "hg repo version: ${hg_root_forest}/${hg_repo_version}"

function runDiff() {
diffNum=$(diff -rq openjdk-git openjdk-hg -x '.git' -x '.hg' -x '.hgtags' | wc -l)
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

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
}
diffNum=$(diff -rq openjdk-git openjdk-hg -x '.git' -x '.hg' -x '.hgtags' | wc -l)

function checkTags() {
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

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

cd openjdk-hg || exit 1
hgTag=$(hg log -r "." --template "{latesttag}\n") || 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

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

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

################################################################################
# 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 $@
set -euo pipefail

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

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
#cleanup
rm -rf openjdk-git openjdk-hg

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

cd - || 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' -x '.hgignore' -x 'get_source.sh' -x 'README.md' | wc -l)
cd openjdk-hg || exit 1
bash get_source.sh
cd - || exit 1

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
}
diffNum=$(diff -rq openjdk-git openjdk-hg -x '.git' -x '.hg' -x '.hgtags' | wc -l)

# This function only checks the latest tag, a future enhancement could be to
# check all tags
function checkLatestTag() {
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

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

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

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
if [ "$gitTag" == "$hgTag" ]; then
echo "Tags are in sync"
else
echo "ERROR - THE TAGS ARE NOT IN SYNC"
exit 1
fi
Loading

0 comments on commit d03d9cf

Please sign in to comment.