From 8b72bd7e42181fde2a02e0d1d382d17dda184199 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Wed, 22 Aug 2018 16:53:12 +0300 Subject: Add support for --commiter-* options in submit-git handler --- brep/submit/submit-git.in | 39 ++++++++++++++++++++++++++++++++++++++- tests/submit/submit-git.test | 6 +++--- 2 files changed, 41 insertions(+), 4 deletions(-) diff --git a/brep/submit/submit-git.in b/brep/submit/submit-git.in index 2f90217..badc084 100644 --- a/brep/submit/submit-git.in +++ b/brep/submit/submit-git.in @@ -183,6 +183,35 @@ set -o errtrace # Trap ERR in functions. @import brep/submit/submit@ @import brep/submit/submit-git@ +# Parse the command line options. +# +committer_name="Submission Handler" +committer_email="noreply@example.com" + +while [ $# -gt 0 ]; do + case $1 in + --committer-name) + shift + committer_name="$1" + shift + ;; + --committer-email) + shift + committer_email="$1" + shift + ;; + *) + break; # The end of options is encountered. + ;; + esac +done + +if [ -z "$committer_name" -o -z "$committer_email" ]; then + error "$usage" +fi + +# Parse the command line arguments. +# if [ "$#" -lt 2 -o "$#" -gt 3 ]; then error "$usage" fi @@ -566,7 +595,15 @@ for i in {1..11}; do git_add "$tgt_dir" "${a#$tgt_dir/}" - run git -C "$tgt_dir" commit $gqo $gvo -F - <&2 + if [ -n "$email" ]; then + e="$email" + else + e="$committer_email" + fi + + GIT_AUTHOR_EMAIL="$e" \ + run git -c "user.name=$committer_name" -c "user.email=$committer_email" \ +-C "$tgt_dir" commit $gqo $gvo -F - <&2 Add $name/$version to $s/$project $(cat "$data_dir/request.manifest") diff --git a/tests/submit/submit-git.test b/tests/submit/submit-git.test index 5a73d65..20745ed 100644 --- a/tests/submit/submit-git.test +++ b/tests/submit/submit-git.test @@ -61,13 +61,13 @@ pkg_ctl="$prj_ctl/hello.git" : none : $* 2>>~%EOE% != 0 - %\[.+\] \[brep:error\] \[ref \] \[brep-submit-git\]: usage: .+brep-submit-git \[\] % + %\[.+\] \[brep:error\] \[ref \] \[brep-submit-git\]: usage: .+brep-submit-git \[\] \[\] % EOE : dir-only : $* $~/dir 2>>~%EOE% != 0 - %\[.+\] \[brep:error\] \[ref dir\] \[brep-submit-git\]: usage: .+brep-submit-git \[\] % + %\[.+\] \[brep:error\] \[ref dir\] \[brep-submit-git\]: usage: .+brep-submit-git \[\] \[\] % EOE : ref-not-exist @@ -126,7 +126,7 @@ pkg_ctl="$prj_ctl/hello.git" git -C tgt log -1 >>~%EOO% %commit .+% - %Author: .+% + %Author: Submission Handler % %Date: .+% Add libhello/0.1.0 to 1/alpha/hello -- cgit v1.1