aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--brep/submit/submit-git.bash.in20
-rw-r--r--brep/submit/submit-git.in60
-rw-r--r--tests/submit/0f6b1460b3ec/request.manifest3
-rw-r--r--tests/submit/submit-git.test136
4 files changed, 163 insertions, 56 deletions
diff --git a/brep/submit/submit-git.bash.in b/brep/submit/submit-git.bash.in
index d19caaf..06d9b7c 100644
--- a/brep/submit/submit-git.bash.in
+++ b/brep/submit/submit-git.bash.in
@@ -94,14 +94,15 @@ function check_package_duplicate () # <name> <version> <repo-dir>
# Serialize the project or package owner manifest (they have the same set of
# values) to the specified manifest file.
#
-function create_owner_manifest () # <name> <email> <control> <file>
-{
+function create_owner_manifest () # <name> <author-name> <author-email>
+{ # <control> <file>
trace_func "$@"
local nam="$1"
- local eml="$2"
- local ctl="$3"
- local man="$4"
+ local anm="$2"
+ local aem="$3"
+ local ctl="$4"
+ local man="$5"
if [ -f "$man" ]; then
error "'$man' already exists"
@@ -109,10 +110,11 @@ function create_owner_manifest () # <name> <email> <control> <file>
manifest_serializer_start "$man"
- manifest_serialize "" "1" # Start of manifest.
- manifest_serialize "name" "$nam"
- manifest_serialize "email" "$eml"
- manifest_serialize "control" "$ctl"
+ manifest_serialize "" "1" # Start of manifest.
+ manifest_serialize "name" "$nam"
+ manifest_serialize "author-name" "$anm"
+ manifest_serialize "author-email" "$aem"
+ manifest_serialize "control" "$ctl"
manifest_serializer_finish
}
diff --git a/brep/submit/submit-git.in b/brep/submit/submit-git.in
index badc084..0c90309 100644
--- a/brep/submit/submit-git.in
+++ b/brep/submit/submit-git.in
@@ -79,8 +79,9 @@
# creates a new project subdirectory and saves project-owner.manifest. The
# project owner manifest contains the following values in the specified order:
#
-# name: <project-name>
-# email: <submitter-email>
+# name: <project-name>
+# author-name: <name>
+# author-email: <email>
# control: <url-prefix>
#
# The 'control' value is the control repository URL prefix and there can be
@@ -98,8 +99,9 @@
# The package owner manifest contains the following values in the specified
# order:
#
-# name: <package-name>
-# email: <submitter-email>
+# name: <package-name>
+# author-name: <name>
+# author-email: <email>
# control: <url>
#
# The 'control' value is the control repository URL and there can be multiple
@@ -288,18 +290,20 @@ manifest_parser_start "$data_dir/request.manifest"
archive=
sha256sum=
section=
-email=
+author_name=
+author_email=
control=
simulate=
while IFS=: read -ru "$manifest_parser_ofd" -d '' n v; do
case "$n" in
- archive) archive="$v" ;;
- sha256sum) sha256sum="$v" ;;
- section) section="$v" ;;
- email) email="$v" ;;
- control) control="$v" ;;
- simulate) simulate="$v" ;;
+ archive) archive="$v" ;;
+ sha256sum) sha256sum="$v" ;;
+ section) section="$v" ;;
+ author-name) author_name="$v" ;;
+ author-email) author_email="$v" ;;
+ control) control="$v" ;;
+ simulate) simulate="$v" ;;
esac
done
@@ -317,7 +321,17 @@ if [ -n "$simulate" -a "$simulate" != "success" ]; then
exit_with_manifest 400 "unrecognized simulation outcome '$simulate'"
fi
-# Note: checking for section, email, and control later.
+# The author-* manifest values should both be present or absent.
+#
+if [ -z "$author_name" -a -n "$author_email" ]; then
+ exit_with_manifest 400 "author-name manifest value expected"
+fi
+
+if [ -z "$author_email" -a -n "$author_name" ]; then
+ exit_with_manifest 400 "author-email manifest value expected"
+fi
+
+# Note: checking for section, author-*, and control later.
m="$data_dir/package.manifest"
extract_package_manifest "$data_dir/$archive" "$m"
@@ -501,8 +515,8 @@ for i in {1..11}; do
# Check that the necessary request manifest values are specified.
#
- if [ -z "$email" ]; then
- exit_with_manifest 400 "email manifest value expected"
+ if [ -z "$author_name" ]; then
+ exit_with_manifest 400 "author-name manifest value expected"
fi
# Check that the package doesn't belong yet to some other project.
@@ -524,7 +538,9 @@ for i in {1..11}; do
run mkdir -p "$d" # Also creates the owners directory if not exist.
ctl="$(repository_base "$control")"
- create_owner_manifest "$project" "$email" "$ctl" "$prj_man"
+
+ create_owner_manifest \
+ "$project" "$author_name" "$author_email" "$ctl" "$prj_man"
# Add the project owners manifest file to git repository using the path
# relative to the repository directory.
@@ -538,7 +554,9 @@ for i in {1..11}; do
run mkdir "$d"
pkg_man="$d/package-owner.manifest"
- create_owner_manifest "$name" "$email" "$control" "$pkg_man"
+
+ create_owner_manifest \
+ "$name" "$author_name" "$author_email" "$control" "$pkg_man"
# Add the package owners manifest file using path relative to the
# repository directory.
@@ -595,15 +613,13 @@ for i in {1..11}; do
git_add "$tgt_dir" "${a#$tgt_dir/}"
- if [ -n "$email" ]; then
- e="$email"
- else
- e="$committer_email"
+ author=()
+ if [ -n "$author_name" ]; then
+ author=(--author="$author_name <$author_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
+-C "$tgt_dir" commit "${author[@]}" $gqo $gvo -F - <<EOF >&2
Add $name/$version to $s/$project
$(cat "$data_dir/request.manifest")
diff --git a/tests/submit/0f6b1460b3ec/request.manifest b/tests/submit/0f6b1460b3ec/request.manifest
index 1173210..a5ecde8 100644
--- a/tests/submit/0f6b1460b3ec/request.manifest
+++ b/tests/submit/0f6b1460b3ec/request.manifest
@@ -6,5 +6,6 @@ client-ip: fe80::56e1:adff:fe83:82f5
user-agent: bdep/0.8.0-a.0.20180815130917 (GNU/Linux; +https://build2.org)\
libbpkg/0.8.0-a.0.0f50af28d1cf libbutl/0.8.0-a.0.3e0db12932d5 curl
section: alpha
-email: user@example.org
+author-name: User Name
+author-email: user@example.org
control: http://example.org/hello.git
diff --git a/tests/submit/submit-git.test b/tests/submit/submit-git.test
index 20745ed..a64e9a1 100644
--- a/tests/submit/submit-git.test
+++ b/tests/submit/submit-git.test
@@ -86,13 +86,17 @@ pkg_ctl="$prj_ctl/hello.git"
: ownership is successfully aquired. Authentication is enabled on both the
: reference and target repos.
:
+ : Note that here we also test that --commiter-* options are picked up
+ : properly.
+ :
{
$clone_root_data;
$clone_root_tgt;
tgt_url = "file:///$~/tgt.git";
- $* "$tgt_url" $root_ref_dir $data_dir >>"EOO";
+ $* --committer-name 'Commiter' --committer-email 'commiter@example.com' \
+ "$tgt_url" $root_ref_dir $data_dir >>"EOO";
: 1
status: 200
message: libhello/0.1.0 submission is queued
@@ -109,7 +113,8 @@ pkg_ctl="$prj_ctl/hello.git"
cat tgt/owners/hello/project-owner.manifest >>~%EOO%;
: 1
name: hello
- email: user@example.org
+ author-name: User Name
+ author-email: user@example.org
%control: file:///.+%
%.*
EOO
@@ -117,16 +122,17 @@ pkg_ctl="$prj_ctl/hello.git"
cat tgt/owners/hello/libhello/package-owner.manifest >>~%EOO%;
: 1
name: libhello
- email: user@example.org
+ author-name: User Name
+ author-email: user@example.org
%control: file:///.+%
%.*
EOO
test -f tgt/1/alpha/hello/libhello-0.1.0.tar.gz;
- git -C tgt log -1 >>~%EOO%
+ git -C tgt log -1 >>~%EOO%;
%commit .+%
- %Author: Submission Handler <user@example.org>%
+ %Author: User Name <user@example.org>%
%Date: .+%
Add libhello/0.1.0 to 1/alpha/hello
@@ -139,11 +145,17 @@ pkg_ctl="$prj_ctl/hello.git"
% user-agent: bdep/.+%
%.
section: alpha
- email: user@example.org
+ author-name: User Name
+ author-email: user@example.org
% control: file:///.+%
%.*
EOO
+
+ git -C tgt log -1 "--pretty=format:%an %ae %cn %ce" >>:EOO
+ User Name user@example.org Commiter commiter@example.com
+ EOO
}
+
: ref-disabled-tgt-aquire-prj-pkg
:
: Test that on the first package submit the project and package names
@@ -210,14 +222,16 @@ pkg_ctl="$prj_ctl/hello.git"
cat <<"EOI" >=tgt/owners/hello/project-owner.manifest;
: 1
name: hello
- email: user@example.org
+ author-name: User Name
+ author-email: user@example.org
control: $prj_ctl/
EOI
cat <<"EOI" >=tgt/owners/hello/libhello/package-owner.manifest;
: 1
name: libhello
- email: user@example.org
+ author-name: User Name
+ author-email: user@example.org
control: $pkg_ctl
EOI
@@ -239,8 +253,11 @@ pkg_ctl="$prj_ctl/hello.git"
: repository and the package ownersip is authenticated by the target
: repository.
:
+ : Note that here we also test an author-less submission.
+ :
{
$clone_root_data;
+ sed -i -e "s%^author-.+\$%%" $data_dir/request.manifest;
$clone_root_ref;
$g clone ref.git &ref/***;
@@ -250,7 +267,8 @@ pkg_ctl="$prj_ctl/hello.git"
cat <<"EOI" >=ref/owners/hello/project-owner.manifest;
: 1
name: hello
- email: user@example.org
+ author-name: User Name
+ author-email: user@example.org
control: $prj_ctl/
EOI
@@ -266,7 +284,8 @@ pkg_ctl="$prj_ctl/hello.git"
cat <<"EOI" >=tgt/owners/hello/libhello/package-owner.manifest;
: 1
name: libhello
- email: user@example.org
+ author-name: User Name
+ author-email: user@example.org
control: $pkg_ctl
EOI
@@ -274,12 +293,20 @@ pkg_ctl="$prj_ctl/hello.git"
$g -C tgt commit -m 'Add ownership info';
$g -C tgt push;
- $* "file:///$~/tgt.git" ref $data_dir >>"EOO"
+ $* "file:///$~/tgt.git" ref $data_dir >>"EOO";
: 1
status: 200
message: libhello/0.1.0 submission is queued
reference: $checksum
EOO
+
+ # Check that the author/committer names/emails are properly assigned.
+ #
+ $g -C tgt pull;
+
+ git -C tgt log -1 "--pretty=format:%an %ae %cn %ce" >>:EOO
+ Submission Handler noreply@example.com Submission Handler noreply@example.com
+ EOO
}
: ref-auth-prj-pkg
@@ -301,14 +328,16 @@ pkg_ctl="$prj_ctl/hello.git"
cat <<"EOI" >=ref/owners/hello/project-owner.manifest;
: 1
name: hello
- email: user@example.org
+ author-name: User Name
+ author-email: user@example.org
control: $regex.replace("$prj_ctl", '(.*/)[^/]*', '\1')
EOI
cat <<"EOI" >=ref/owners/hello/libhello/package-owner.manifest;
: 1
name: libhello
- email: user@example.org
+ author-name: User Name
+ author-email: user@example.org
control: $pkg_ctl
EOI
@@ -342,7 +371,8 @@ pkg_ctl="$prj_ctl/hello.git"
cat <<"EOI" >=ref/owners/hello/project-owner.manifest;
: 1
name: hello
- email: user@example.org
+ author-name: User Name
+ author-email: user@example.org
control: $prj_ctl/
EOI
@@ -423,6 +453,54 @@ pkg_ctl="$prj_ctl/hello.git"
: failure
:
{
+ : no-author
+ :
+ {
+ $clone_root_data_clean;
+ sed -i -e "s%^author-.+\$%%" $data_dir/request.manifest;
+
+ $clone_root_tgt;
+ tgt_url = "file:///$~/tgt.git";
+
+ $* "$tgt_url" $root_ref_dir $data_dir >>"EOO"
+ : 1
+ status: 400
+ message: author-name manifest value expected
+ EOO
+ }
+
+ : no-author-email
+ :
+ {
+ $clone_root_data_clean;
+ sed -i -e "s%^author-email.+\$%%" $data_dir/request.manifest;
+
+ $clone_root_tgt;
+ tgt_url = "file:///$~/tgt.git";
+
+ $* "$tgt_url" $root_ref_dir $data_dir >>"EOO"
+ : 1
+ status: 400
+ message: author-email manifest value expected
+ EOO
+ }
+
+ : no-author-name
+ :
+ {
+ $clone_root_data_clean;
+ sed -i -e "s%^author-name.+\$%%" $data_dir/request.manifest;
+
+ $clone_root_tgt;
+ tgt_url = "file:///$~/tgt.git";
+
+ $* "$tgt_url" $root_ref_dir $data_dir >>"EOO"
+ : 1
+ status: 400
+ message: author-name manifest value expected
+ EOO
+ }
+
: ref-dup-pkg
:
: Test the duplicate submission due presence of the package archive in the
@@ -464,14 +542,16 @@ pkg_ctl="$prj_ctl/hello.git"
cat <<"EOI" >=ref/owners/hi/project-owner.manifest;
: 1
name: hi
- email: user@example.org
+ author-name: User Name
+ author-email: user@example.org
control: $prj_ctl/
EOI
cat <<"EOI" >=ref/owners/hi/libhello/package-owner.manifest;
: 1
name: libhello
- email: user@example.org
+ author-name: User Name
+ author-email: user@example.org
control: $prj_ctl/foo
EOI
@@ -501,7 +581,8 @@ pkg_ctl="$prj_ctl/hello.git"
cat <<EOI >=ref/owners/hello/project-owner.manifest;
: 1
name: hello
- email: user@example.org
+ author-name: User Name
+ author-email: user@example.org
control: https://example.com/foo
EOI
@@ -532,14 +613,16 @@ pkg_ctl="$prj_ctl/hello.git"
cat <<"EOI" >=ref/owners/hello/project-owner.manifest;
: 1
name: hello
- email: user@example.org
+ author-name: User Name
+ author-email: user@example.org
control: $prj_ctl/
EOI
cat <<"EOI" >=ref/owners/hello/libhello/package-owner.manifest;
: 1
name: libhello
- email: user@example.org
+ author-name: User Name
+ author-email: user@example.org
control: $prj_ctl/foo
EOI
@@ -594,14 +677,16 @@ pkg_ctl="$prj_ctl/hello.git"
cat <<"EOI" >=tgt/owners/hello/project-owner.manifest;
: 1
name: hello
- email: user@example.org
+ author-name: User Name
+ author-email: user@example.org
control: $prj_ctl/
EOI
cat <<"EOI" >=tgt/owners/hello/libhello/package-owner.manifest;
: 1
name: libhello
- email: user@example.org
+ author-name: User Name
+ author-email: user@example.org
control: $prj_ctl/foo
EOI
@@ -663,7 +748,8 @@ pkg_ctl="$prj_ctl/hello.git"
cat <<"EOI" >=ref/owners/hello/project-owner.manifest;
: 1
name: hello
- email: user@example.org
+ author-name: User Name
+ author-email: user@example.org
control: $prj_ctl/
EOI
@@ -708,14 +794,16 @@ pkg_ctl="$prj_ctl/hello.git"
cat <<"EOI" >=tgt/owners/hi/project-owner.manifest;
: 1
name: hi
- email: user@example.org
+ author-name: User Name
+ author-email: user@example.org
control: $prj_ctl/
EOI
cat <<"EOI" >=tgt/owners/hi/libhello/package-owner.manifest;
: 1
name: libhello
- email: user@example.org
+ author-name: User Name
+ author-email: user@example.org
control: $prj_ctl/foo
EOI