]> git.apps.os.sepia.ceph.com Git - ceph-build.git/commitdiff
ceph-ansible-pr-syntax-check: add two functions to search files
authorSébastien Han <seb@redhat.com>
Wed, 22 Aug 2018 09:25:52 +0000 (11:25 +0200)
committerSébastien Han <seb@redhat.com>
Wed, 22 Aug 2018 09:25:52 +0000 (11:25 +0200)
Adding 2 new functions:

* git_diff_to_head which prints the diff for the current new code
* match_file which searches and print a particular file that was
modified by the current code.

Signed-off-by: Sébastien Han <seb@redhat.com>
ceph-ansible-pr-syntax-check/build/build

index 77a6f684dc344c995323649d69bdd23e0a86b739..5fb4fce4026e9aea99aeeb11b3d0d434c4b29837 100644 (file)
@@ -47,10 +47,16 @@ function group_vars_check {
   fi
 }
 
-function test_sign_off {
-  git fetch
+function git_diff_to_head {
   # shellcheck disable=SC2154
   # ghprbTargetBranch variable comes from jenkins's injectedEnvVars
+  git diff origin/"${ghprbTargetBranch}"..HEAD
+}
+
+function match_file {
+  git_diff_to_head | sed -n "s|^+++.*\\($1.*\\)|\\1|p"
+}
+
   test "$(git log --oneline --no-merges origin/"${ghprbTargetBranch}"..HEAD | wc -l)" -ne "$(git log --no-merges origin/"${ghprbTargetBranch}"..HEAD | grep -c Signed-off-by)" && echo "One or more commits is/are missing a Signed-off-by. Add it with 'git commit -s'." && return 1
 
   # if we arrive here the test command successed and we can return 0