Skip to content

Commit 6448eed

Browse files
committed
melting-pot: fix cached repo tag updating
And avoid use of ambiguous dir variable. And fix fast-fail behavior when source resolution fails.
1 parent 6ca99de commit 6448eed

File tree

1 file changed

+19
-8
lines changed

1 file changed

+19
-8
lines changed

melting-pot.sh

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -441,13 +441,23 @@ resolveSource() {
441441
# Check whether the needed branch/tag exists.
442442
local scmBranch
443443
test "$2" && scmBranch="$2" || scmBranch="$(scmTag "$1")"
444+
test "$scmBranch" || die "$1: cannot glean SCM tag" 14
444445
debug "git ls-remote \"file://$cachedRepoDir\" | grep -q \"\brefs/tags/$scmBranch$\""
445446
git ls-remote "file://$cachedRepoDir" | grep -q "\brefs/tags/$scmBranch$" || {
446447
# Couldn't find the scmBranch as a tag in the cached repo. Either the
447448
# tag is new, or it's not a tag ref at all (e.g. it's a branch).
448449
# So let's update from the original remote repository.
449-
info "$1: local tag not found for ref '$scmBranch'; updating cached repository: $cachedRepoDir"
450-
(cd "$cachedRepoDir" && debug "git fetch --tags" && git fetch --tags)
450+
info "$1: local tag not found for ref '$scmBranch'"
451+
info "$1: updating cached repository: $cachedRepoDir"
452+
cd "$cachedRepoDir"
453+
debug "git fetch --tags"
454+
if [ "$debug" ]
455+
then
456+
git fetch --tags
457+
else
458+
git fetch --tags > /dev/null
459+
fi
460+
cd - > /dev/null
451461
}
452462

453463
# Shallow clone the source at the given version into melting-pot structure.
@@ -467,7 +477,7 @@ resolveSource() {
467477

468478
# Gets the list of dependencies for the project in the CWD.
469479
deps() {
470-
cd "$1"
480+
cd "$1" || die "No such directory: $1" 16
471481
debug "mvn -DincludeScope=runtime -B dependency:list"
472482
local depList="$(mvn -DincludeScope=runtime -B dependency:list)" ||
473483
die "Problem fetching dependencies!" 5
@@ -643,17 +653,18 @@ meltDown() {
643653
test -f "$1/pom.xml" || die "Not a Maven project: $1" 12
644654
info "Local Maven project: $1"
645655
mkdir -p "LOCAL"
646-
local dir="LOCAL/PROJECT"
647-
ln -s "$1" "$dir"
656+
local projectDir="LOCAL/PROJECT"
657+
ln -s "$1" "$projectDir"
648658
else
649659
# Treat specified project as a GAV.
650660
info "Fetching project source"
651-
resolveSource "$1" "$branch"
661+
local projectDir=$(resolveSource "$1" "$branch")
662+
test $? -eq 0 || exit $?
652663
fi
653664

654665
# Get the project dependencies.
655666
info "Determining project dependencies"
656-
local deps="$(deps "$dir")"
667+
local deps="$(deps "$projectDir")"
657668
test "$deps" || die "Cannot glean project dependencies" 7
658669

659670
local args="-Denforcer.skip"
@@ -676,7 +687,7 @@ meltDown() {
676687
if [ "$(isIncluded "$gav")" ]
677688
then
678689
info "$g:$a: resolving source for version $v"
679-
dir="$(resolveSource "$gav")"
690+
resolveSource "$gav" >/dev/null
680691
fi
681692
done
682693

0 commit comments

Comments
 (0)