diff options
author | Karen Arutyunov <karen@codesynthesis.com> | 2018-08-22 16:53:12 +0300 |
---|---|---|
committer | Karen Arutyunov <karen@codesynthesis.com> | 2018-08-22 16:55:38 +0300 |
commit | 8b72bd7e42181fde2a02e0d1d382d17dda184199 (patch) | |
tree | 018f42a5aa2804c9dc3d7b7e59187f1e2371f6cb | |
parent | 6dff80b189a649f64a885a553ceefe1055cdb21e (diff) |
Add support for --commiter-* options in submit-git handler
-rw-r--r-- | brep/submit/submit-git.in | 39 | ||||
-rw-r--r-- | 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 - <<EOF >&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 - <<EOF >&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 <tgt-repo> \[<ref-repo>\] <dir>% + %\[.+\] \[brep:error\] \[ref \] \[brep-submit-git\]: usage: .+brep-submit-git \[<options>\] <tgt-repo> \[<ref-repo>\] <dir>% EOE : dir-only : $* $~/dir 2>>~%EOE% != 0 - %\[.+\] \[brep:error\] \[ref dir\] \[brep-submit-git\]: usage: .+brep-submit-git <tgt-repo> \[<ref-repo>\] <dir>% + %\[.+\] \[brep:error\] \[ref dir\] \[brep-submit-git\]: usage: .+brep-submit-git \[<options>\] <tgt-repo> \[<ref-repo>\] <dir>% 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 <user@example.org>% %Date: .+% Add libhello/0.1.0 to 1/alpha/hello |