proj/gagit:main commit in: test/, /

Michał Górny <[email protected]> Wed, 05 Aug 2026 15:26:58 +0000 (UTC)
Newsgroups gmane.linux.gentoo.cvs
Message-ID <1785943595.137ea9b2ac612e8b2a2aa9fe8328ac646b706e8d.mgorny@gentoo>
commit:     137ea9b2ac612e8b2a2aa9fe8328ac646b706e8d
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Wed Aug  5 15:25:00 2026 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Wed Aug  5 15:26:35 2026 +0000
URL:        https://gitweb.gentoo.org/proj/gagit.git/commit/?id=137ea9b2

Add editing tests

Signed-off-by: Michał Górny <mgorny <AT> gentoo.org>

 meson.build    |  1 +
 test/26edit.sh | 75 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 76 insertions(+)

diff --git a/meson.build b/meson.build
index 199ffc5..28a72fd 100644
--- a/meson.build
+++ b/meson.build
@@ -27,6 +27,7 @@ tests = [
   '23topic',
   '24template',
   '25title-desc',
+  '26edit',
 ]
 
 foreach t : tests

diff --git a/test/26edit.sh b/test/26edit.sh
new file mode 100644
index 0000000..fc122db
--- /dev/null
+++ b/test/26edit.sh
@@ -0,0 +1,75 @@
+#!/usr/bin/env bash
+# Test that editing works as expected.
+
+set -e -x
+
+. common-setup.sh
+repository_setup codeberg foo dev
+git commit --allow-empty -m "test commit
+
+test body"
+
+> new-text
+cat > editor <<-EOF
+	#!/usr/bin/env bash
+	# replace \${1} with our test file
+	cat '${PWD}'/new-text > "\${1}"
+EOF
+
+# empty file should result in an error
+STDERR=$(! bash "${INITDIR}"/../gagit -e "bash ${PWD}/editor" -n 2>&1 >/dev/null)
+[[ ${STDERR} == *'No pull request description provided'* ]]
+
+# same for file with whitespace and comments only
+cat > new-text <<-EOF
+   
+# test comment
+  
+
+
+EOF
+STDERR=$(! bash "${INITDIR}"/../gagit -e "bash ${PWD}/editor" -n 2>&1 >/dev/null)
+[[ ${STDERR} == *'No pull request description provided'* ]]
+
+# set a new title
+cat > new-text <<-EOF
+   
+# test comment
+  new title
+
+# more comments
+EOF
+# T: new title
+# D: empty (\n)
+STDERR=$(bash "${INITDIR}"/../gagit -e "bash ${PWD}/editor" -n 2>&1 >/dev/null)
+[[ ${STDERR} == *"+ 'git' 'push' '-o' 'title={base64}bmV3IHRpdGxlCg==' '-o' 'description={base64}Cg=='"* ]]
+
+# set a new title and description
+cat > new-text <<-EOF
+   
+# test comment
+  new title
+
+# more comments
+new description
+EOF
+# T: new title
+# D: new description
+STDERR=$(bash "${INITDIR}"/../gagit -e "bash ${PWD}/editor" -n 2>&1 >/dev/null)
+[[ ${STDERR} == *"+ 'git' 'push' '-o' 'title={base64}bmV3IHRpdGxlCg==' '-o' 'description={base64}bmV3IGRlc2NyaXB0aW9uCgo='"* ]]
+
+# set a new title and description interspersed with comments
+cat > new-text <<-EOF
+   
+# test comment
+  new title
+
+# more comments
+new description
+# some more
+another line
+EOF
+# T: new title
+# D: new description \n another line
+STDERR=$(bash "${INITDIR}"/../gagit -e "bash ${PWD}/editor" -n 2>&1 >/dev/null)
+[[ ${STDERR} == *"+ 'git' 'push' '-o' 'title={base64}bmV3IHRpdGxlCg==' '-o' 'description={base64}bmV3IGRlc2NyaXB0aW9uCmFub3RoZXIgbGluZQoK'"* ]]