Bug #19244
closed
ceph-pr-submodules jenkins job doesn't work
Added by Dan Mick about 7 years ago.
Updated almost 7 years ago.
Description
git submodule foreach doesn't work on a fresh clone; the only thing I can find to get it to work is a git submodule update.
Also, checking for 'any output' from git submodule (with [[ $submodule_output ]]) is wrong; you get output even if there are no inconsistencies.
Also, recently, we had a case where a random subdir got added back, but had no contents, which causes the 'submodule foreach' to lose it. Need to check for an error code from it as well.
Working on a fix.
- Subject changed from ceph-pr-submodules jenkin job doesn't work to ceph-pr-submodules jenkins job doesn't work
still has to have a git submodule update, but maybe
As a piece of this puzzle: a generic method for specifying the range of commits in the pull request is
git fetch origin $ghprbTargetBranch
git log --oneline refs/remotes/origin/$ghprbTargetBranch..$ghprbActualCommit
TargetBranch is the branch into which the PR wants to merge, and ActualCommit is the SHA1 of the tip of the PR's branch, so this shows all commits in the PR branch that are not already in the existing branch. This should be the set of commits that are searched for changes to submodules.
This is what I'm looking at:
--- a/ceph-pr-submodules/build/build
+++ b/ceph-pr-submodules/build/build
@@ -4,12 +4,11 @@ set -ex
cd "$WORKSPACE"
-# The command below has access to the variables $name, $path, $sha1 and $toplevel:
-# $name is the name of the relevant submodule section in .gitmodules, $path is
-# the name of the submodule directory relative to the superproject, $sha1 is
-# the commit as recorded in the superproject, and $toplevel is the absolute
-# path to the top-level of the superproject.
-modified_submodules=$(git submodule foreach 'cd $toplevel; git diff --ignore-submodules=dirty origin/master -- $path')
+# show diffs between $ghprbTargetBranch (where the merge is going) and
+# $ghprbActiveCommit (the tip of the branch that's merging) with '...',
+# which is equivalent to diff $(git merge-base TB AC) AC. With
+# --submodule, also show detail of diff in submodules.
+modified_submodules="$(git diff --submodule=log $ghprbTargetBranch...$ghprbActiveCommit | grep ^Submodule)"
if [[ $modified_submodules ]]; then
echo "Project has modified submodules!"
That looks a lot better than the current implementation
- Status changed from 12 to Fix Under Review
- Status changed from Fix Under Review to Resolved
Also available in: Atom
PDF