Skip to content

Conversation

@stsquad
Copy link

@stsquad stsquad commented Jan 5, 2023

So much of my workflow is in emacs org-mode that I want to better support scripted calls to git-publish. After modernising the options parsing code I add a few new options to support that.

For an example my org file now looks like this:

*** Publish the results
:PROPERTIES:
:header-args+: :var tree="" :var base=""
:END:

We need to force the :dir for our find-unreviewed-patches call for some reason

#+name: git-publish-prepare
#+header: :results output
#+header: :var needs_review=find-unreviewed-patches-elisp[:dir /home/alex/lsrc/qemu.git]()
#+begin_src sh :async
  branch=$(git symbolic-ref --short HEAD)
  base=${revspec%%..*}
  echo "Working on $branch, based off $base in $PWD"
  # with prefix reset everything
  if test -n "$prefix"; then
      git tag -d ${branch}-staging
  fi
  git tag -l --format="%(contents)" ${branch}-staging > ${branch}.cover
  # Cut any old needs review data?
  lines=$(grep -n "The following patches need review" ${branch}.cover | cut -f1 -d: | head -n1)
  if test -n "${lines}"; then
     keep=$(expr ${lines} - 1)
     echo "Stripping everything after ${keep}"
     head -n $keep ${branch}.cover > ${branch}.cover.tmp
     mv ${branch}.cover.tmp ${branch}.cover
  fi
  # Add needs review to the cover letter
  echo "" >> ${branch}.cover
  echo "The following patches need review:" >> ${branch}.cover
  echo "" >> ${branch}.cover
  echo "${needs_review}" >> ${branch}.cover
  git tag -f -F ${branch}.cover ${branch}-staging
  echo $EDITOR
  git-publish --base ${base} --edit
#+end_src

#+RESULTS: git-publish-prepare
: Working on gdbstub/next, based off origin/master in /home/alex/lsrc/qemu.git
: Stripping everything after 5
: Updated tag 'gdbstub/next-staging' (was e8dcee1e46)
: emacsclient -a ''
: Waiting for Emacs...

#+name: git-publish-dry-run
#+header: :results output
#+begin_src sh :async
  branch=$(git symbolic-ref --short HEAD)
  base=${revspec%%..*}
  git publish -v --base ${base} --skip-final-edit --no-inspect-emails --dry-run
#+end_src

#+RESULTS: git-publish-dry-run
#+begin_example
git rev-parse --show-toplevel
git rev-parse --git-dir
git symbolic-ref --short HEAD
git tag -l gdbstub/next-v[0-9]*
git config --get-all branch.gdbstub/next.gitpublishto
git config --get-all branch.gdbstub/next.gitpublishcc
git config branch.gdbstub/next.gitpublishcccmd
git config git-publish.signingkey
git config core.hooksPath
git rev-parse --git-common-dir
git shortlog origin/master..gdbstub/next
git diff --stat origin/master..gdbstub/next
git tag -l --format=%(contents) gdbstub/next-staging
git config branch.gdbstub/next.gitpublishprefix
git config format.subjectprefix
git tag -l --format=%(contents) gdbstub/next-staging
git log --no-color --oneline origin/master..
git format-patch --subject-prefix "PATCH v3" --output-directory /tmp/tmp8n8gpcep --numbered --cover-letter --cover-from-description=none origin/master..
git config core.hooksPath
git send-email --to alex.bennee@gmail.com --to qemu-devel@nongnu.org --cc Xiaojuan Yang <yangxiaojuan@loongson.cn> --cc Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk> --cc Eduardo Habkost <eduardo@habkost.net> --cc Peter Maydell <peter.maydell@linaro.org> --cc "Philippe Mathieu-Daudé" <philmd@linaro.org> --cc Chris Wulff <crwulff@gmail.com> --cc Yanan Wang <wangyanan55@huawei.com> --cc � --cc Sunil Muthuswamy <sunilmut@microsoft.com> --cc Richard Henderson <richard.henderson@linaro.org> --cc Daniel Henrique Barboza <danielhb413@gmail.com> --cc Alistair Francis <alistair.francis@wdc.com> --cc Greg Kurz <groug@kaod.org> --cc Aurelien Jarno <aurelien@aurel32.net> --cc qemu-riscv@nongnu.org --cc Taylor Simpson <tsimpson@quicinc.com> --cc Stafford Horne <shorne@gmail.com> --cc Yoshinori Sato <ysato@users.sourceforge.jp> --cc Artyom Tarasenko <atar4qemu@gmail.com> --cc David Gibson <david@gibson.dropbear.id.au> --cc David Hildenbrand <david@redhat.com> --cc "Alex Bennée" <alex.bennee@linaro.org> --cc qemu-s390x@nongnu.org --cc Alexandre Iooss <erdnaxe@crans.org> --cc Paolo Bonzini <pbonzini@redhat.com> --cc Ilya Leoshkevich <iii@linux.ibm.com> --cc Aleksandar Rikalo <aleksandar.rikalo@syrmia.com> --cc Bin Meng <bin.meng@windriver.com> --cc Thomas Huth <thuth@redhat.com> --cc Jiaxun Yang <jiaxun.yang@flygoat.com> --cc "Edgar E. Iglesias" <edgar.iglesias@gmail.com> --cc Michael Rolnik <mrolnik@gmail.com> --cc Mahmoud Mandour <ma.mandourr@gmail.com> --cc Laurent Vivier <laurent@vivier.eu> --cc qemu-ppc@nongnu.org --cc Marcel Apfelbaum <marcel.apfelbaum@gmail.com> --cc "Cédric Le Goater" <clg@kaod.org> --cc qemu-arm@nongnu.org --cc Song Gao <gaosong@loongson.cn> --cc Max Filippov <jcmvbkbc@gmail.com> --cc Palmer Dabbelt <palmer@dabbelt.com> --cc Marek Vasut <marex@denx.de> --cc Bastian Koppelmann <kbastian@mail.uni-paderborn.de> --thread --dry-run --relogin-delay=0 --batch-size=0 --confirm=never /tmp/tmp8n8gpcep/0000-cover-letter.patch /tmp/tmp8n8gpcep/0001-gdbstub-internals.h-clean-up-include-guard.patch /tmp/tmp8n8gpcep/0002-target-arm-fix-handling-of-HLT-semihosting-in-system.patch /tmp/tmp8n8gpcep/0003-gdbstub-fix-up-copyright-and-license-files.patch /tmp/tmp8n8gpcep/0004-gdbstub-Make-syscall_complete-gs-et_reg-target-agnos.patch /tmp/tmp8n8gpcep/0005-gdbstub-define-separate-user-system-structures.patch /tmp/tmp8n8gpcep/0006-gdbstub-move-GDBState-to-shared-internals-header.patch /tmp/tmp8n8gpcep/0007-includes-move-tb_flush-into-its-own-header.patch /tmp/tmp8n8gpcep/0008-gdbstub-move-fromhex-tohex-routines-to-internals.patch /tmp/tmp8n8gpcep/0009-gdbstub-make-various-helpers-visible-to-the-rest-of-.patch /tmp/tmp8n8gpcep/0010-gdbstub-move-chunk-of-softmmu-functionality-to-own-f.patch /tmp/tmp8n8gpcep/0011-gdbstub-move-chunks-of-user-code-into-own-files.patch /tmp/tmp8n8gpcep/0012-gdbstub-abstract-target-specific-details-from-gdb_pu.patch /tmp/tmp8n8gpcep/0013-gdbstub-specialise-handle_query_attached.patch /tmp/tmp8n8gpcep/0014-gdbstub-specialise-target_memory_rw_debug.patch /tmp/tmp8n8gpcep/0015-gdbstub-introduce-gdb_get_max_cpus.patch /tmp/tmp8n8gpcep/0016-gdbstub-specialise-stub_can_reverse.patch /tmp/tmp8n8gpcep/0017-gdbstub-fix-address-type-of-gdb_set_cpu_pc.patch /tmp/tmp8n8gpcep/0018-gdbstub-don-t-use-target_ulong-while-handling-regist.patch /tmp/tmp8n8gpcep/0019-gdbstub-move-register-helpers-into-standalone-includ.patch /tmp/tmp8n8gpcep/0020-gdbstub-move-syscall-handling-to-new-file.patch /tmp/tmp8n8gpcep/0021-gdbstub-only-compile-gdbstub-twice-for-whole-build.patch /tmp/tmp8n8gpcep/0022-testing-probe-gdb-for-supported-architectures-ahead-.patch
git config --unset-all branch.gdbstub/next.gitpublishto
git config --add branch.gdbstub/next.gitpublishto alex.bennee@gmail.com
git config --add branch.gdbstub/next.gitpublishto qemu-devel@nongnu.org
git config --unset-all branch.gdbstub/next.gitpublishcc
git config --add branch.gdbstub/next.gitpublishcc "Xiaojuan Yang <yangxiaojuan@loongson.cn>"
git config --add branch.gdbstub/next.gitpublishcc "Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>"
git config --add branch.gdbstub/next.gitpublishcc "Eduardo Habkost <eduardo@habkost.net>"
git config --add branch.gdbstub/next.gitpublishcc "Peter Maydell <peter.maydell@linaro.org>"
git config --add branch.gdbstub/next.gitpublishcc ""Philippe Mathieu-Daudé" <philmd@linaro.org>"
git config --add branch.gdbstub/next.gitpublishcc "Chris Wulff <crwulff@gmail.com>"
git config --add branch.gdbstub/next.gitpublishcc "Yanan Wang <wangyanan55@huawei.com>"
git config --add branch.gdbstub/next.gitpublishcc �
git config --add branch.gdbstub/next.gitpublishcc "Sunil Muthuswamy <sunilmut@microsoft.com>"
git config --add branch.gdbstub/next.gitpublishcc "Richard Henderson <richard.henderson@linaro.org>"
git config --add branch.gdbstub/next.gitpublishcc "Daniel Henrique Barboza <danielhb413@gmail.com>"
git config --add branch.gdbstub/next.gitpublishcc "Alistair Francis <alistair.francis@wdc.com>"
git config --add branch.gdbstub/next.gitpublishcc "Greg Kurz <groug@kaod.org>"
git config --add branch.gdbstub/next.gitpublishcc "Aurelien Jarno <aurelien@aurel32.net>"
git config --add branch.gdbstub/next.gitpublishcc qemu-riscv@nongnu.org
git config --add branch.gdbstub/next.gitpublishcc "Taylor Simpson <tsimpson@quicinc.com>"
git config --add branch.gdbstub/next.gitpublishcc "Stafford Horne <shorne@gmail.com>"
git config --add branch.gdbstub/next.gitpublishcc "Yoshinori Sato <ysato@users.sourceforge.jp>"
git config --add branch.gdbstub/next.gitpublishcc "Artyom Tarasenko <atar4qemu@gmail.com>"
git config --add branch.gdbstub/next.gitpublishcc "David Gibson <david@gibson.dropbear.id.au>"
git config --add branch.gdbstub/next.gitpublishcc "David Hildenbrand <david@redhat.com>"
git config --add branch.gdbstub/next.gitpublishcc ""Alex Bennée" <alex.bennee@linaro.org>"
git config --add branch.gdbstub/next.gitpublishcc qemu-s390x@nongnu.org
git config --add branch.gdbstub/next.gitpublishcc "Alexandre Iooss <erdnaxe@crans.org>"
git config --add branch.gdbstub/next.gitpublishcc "Paolo Bonzini <pbonzini@redhat.com>"
git config --add branch.gdbstub/next.gitpublishcc "Ilya Leoshkevich <iii@linux.ibm.com>"
git config --add branch.gdbstub/next.gitpublishcc "Aleksandar Rikalo <aleksandar.rikalo@syrmia.com>"
git config --add branch.gdbstub/next.gitpublishcc "Bin Meng <bin.meng@windriver.com>"
git config --add branch.gdbstub/next.gitpublishcc "Thomas Huth <thuth@redhat.com>"
git config --add branch.gdbstub/next.gitpublishcc "Jiaxun Yang <jiaxun.yang@flygoat.com>"
git config --add branch.gdbstub/next.gitpublishcc ""Edgar E. Iglesias" <edgar.iglesias@gmail.com>"
git config --add branch.gdbstub/next.gitpublishcc "Michael Rolnik <mrolnik@gmail.com>"
git config --add branch.gdbstub/next.gitpublishcc "Mahmoud Mandour <ma.mandourr@gmail.com>"
git config --add branch.gdbstub/next.gitpublishcc "Laurent Vivier <laurent@vivier.eu>"
git config --add branch.gdbstub/next.gitpublishcc qemu-ppc@nongnu.org
git config --add branch.gdbstub/next.gitpublishcc "Marcel Apfelbaum <marcel.apfelbaum@gmail.com>"
git config --add branch.gdbstub/next.gitpublishcc ""Cédric Le Goater" <clg@kaod.org>"
git config --add branch.gdbstub/next.gitpublishcc qemu-arm@nongnu.org
git config --add branch.gdbstub/next.gitpublishcc "Song Gao <gaosong@loongson.cn>"
git config --add branch.gdbstub/next.gitpublishcc "Max Filippov <jcmvbkbc@gmail.com>"
git config --add branch.gdbstub/next.gitpublishcc "Palmer Dabbelt <palmer@dabbelt.com>"
git config --add branch.gdbstub/next.gitpublishcc "Marek Vasut <marex@denx.de>"
git config --add branch.gdbstub/next.gitpublishcc "Bastian Koppelmann <kbastian@mail.uni-paderborn.de>"
#+end_example

And this finally sends it:

#+name: git-publish-final
#+header: :results output
#+begin_src sh :async
  branch=$(git symbolic-ref --short HEAD)
  base=${revspec%%..*}
  git publish -v --base ${base} --skip-final-edit --no-inspect-emails
#+end_src

@stsquad stsquad marked this pull request as ready for review January 5, 2023 21:08
optparse is obsolete and no longer maintained and we should be running
on more modern python3's anyway.

Signed-off-by: Alex Bennée <alex.bennee@linaro.org>

---
v2
  - fix %prog and VERSION handling
v3
  - fix merge conflicts
Otherwise we will blat over whatever we currently have stored. This
behaviour will be more useful with the next patch.

Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Of we are scripting our workflow we might be perfectly happy with what
we last set. Allow the final edit to be skipped and keep the tag with
the message as is.

Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Again this is useful for scripting. We can now test the whole chain
with:

  git publish -v --base origin/master --skip-final-edit --no-inspect-emails --dry-run

before finally hitting the big red button.

Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Using -v is overkill for a script.

Signed-off-by: Alex Bennée <alex.bennee@linaro.org>

---
v2
  - move summary out of the finally step
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants