Skip to content

Add some new options to aid scripted calls to git-publish #116

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

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 [email protected] --to [email protected] --cc Xiaojuan Yang <[email protected]> --cc Mark Cave-Ayland <[email protected]> --cc Eduardo Habkost <[email protected]> --cc Peter Maydell <[email protected]> --cc "Philippe Mathieu-Daudé" <[email protected]> --cc Chris Wulff <[email protected]> --cc Yanan Wang <[email protected]> --cc � --cc Sunil Muthuswamy <[email protected]> --cc Richard Henderson <[email protected]> --cc Daniel Henrique Barboza <[email protected]> --cc Alistair Francis <[email protected]> --cc Greg Kurz <[email protected]> --cc Aurelien Jarno <[email protected]> --cc [email protected] --cc Taylor Simpson <[email protected]> --cc Stafford Horne <[email protected]> --cc Yoshinori Sato <[email protected]> --cc Artyom Tarasenko <[email protected]> --cc David Gibson <[email protected]> --cc David Hildenbrand <[email protected]> --cc "Alex Bennée" <[email protected]> --cc [email protected] --cc Alexandre Iooss <[email protected]> --cc Paolo Bonzini <[email protected]> --cc Ilya Leoshkevich <[email protected]> --cc Aleksandar Rikalo <[email protected]> --cc Bin Meng <[email protected]> --cc Thomas Huth <[email protected]> --cc Jiaxun Yang <[email protected]> --cc "Edgar E. Iglesias" <[email protected]> --cc Michael Rolnik <[email protected]> --cc Mahmoud Mandour <[email protected]> --cc Laurent Vivier <[email protected]> --cc [email protected] --cc Marcel Apfelbaum <[email protected]> --cc "Cédric Le Goater" <[email protected]> --cc [email protected] --cc Song Gao <[email protected]> --cc Max Filippov <[email protected]> --cc Palmer Dabbelt <[email protected]> --cc Marek Vasut <[email protected]> --cc Bastian Koppelmann <[email protected]> --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 [email protected]
git config --add branch.gdbstub/next.gitpublishto [email protected]
git config --unset-all branch.gdbstub/next.gitpublishcc
git config --add branch.gdbstub/next.gitpublishcc "Xiaojuan Yang <[email protected]>"
git config --add branch.gdbstub/next.gitpublishcc "Mark Cave-Ayland <[email protected]>"
git config --add branch.gdbstub/next.gitpublishcc "Eduardo Habkost <[email protected]>"
git config --add branch.gdbstub/next.gitpublishcc "Peter Maydell <[email protected]>"
git config --add branch.gdbstub/next.gitpublishcc ""Philippe Mathieu-Daudé" <[email protected]>"
git config --add branch.gdbstub/next.gitpublishcc "Chris Wulff <[email protected]>"
git config --add branch.gdbstub/next.gitpublishcc "Yanan Wang <[email protected]>"
git config --add branch.gdbstub/next.gitpublishcc �
git config --add branch.gdbstub/next.gitpublishcc "Sunil Muthuswamy <[email protected]>"
git config --add branch.gdbstub/next.gitpublishcc "Richard Henderson <[email protected]>"
git config --add branch.gdbstub/next.gitpublishcc "Daniel Henrique Barboza <[email protected]>"
git config --add branch.gdbstub/next.gitpublishcc "Alistair Francis <[email protected]>"
git config --add branch.gdbstub/next.gitpublishcc "Greg Kurz <[email protected]>"
git config --add branch.gdbstub/next.gitpublishcc "Aurelien Jarno <[email protected]>"
git config --add branch.gdbstub/next.gitpublishcc [email protected]
git config --add branch.gdbstub/next.gitpublishcc "Taylor Simpson <[email protected]>"
git config --add branch.gdbstub/next.gitpublishcc "Stafford Horne <[email protected]>"
git config --add branch.gdbstub/next.gitpublishcc "Yoshinori Sato <[email protected]>"
git config --add branch.gdbstub/next.gitpublishcc "Artyom Tarasenko <[email protected]>"
git config --add branch.gdbstub/next.gitpublishcc "David Gibson <[email protected]>"
git config --add branch.gdbstub/next.gitpublishcc "David Hildenbrand <[email protected]>"
git config --add branch.gdbstub/next.gitpublishcc ""Alex Bennée" <[email protected]>"
git config --add branch.gdbstub/next.gitpublishcc [email protected]
git config --add branch.gdbstub/next.gitpublishcc "Alexandre Iooss <[email protected]>"
git config --add branch.gdbstub/next.gitpublishcc "Paolo Bonzini <[email protected]>"
git config --add branch.gdbstub/next.gitpublishcc "Ilya Leoshkevich <[email protected]>"
git config --add branch.gdbstub/next.gitpublishcc "Aleksandar Rikalo <[email protected]>"
git config --add branch.gdbstub/next.gitpublishcc "Bin Meng <[email protected]>"
git config --add branch.gdbstub/next.gitpublishcc "Thomas Huth <[email protected]>"
git config --add branch.gdbstub/next.gitpublishcc "Jiaxun Yang <[email protected]>"
git config --add branch.gdbstub/next.gitpublishcc ""Edgar E. Iglesias" <[email protected]>"
git config --add branch.gdbstub/next.gitpublishcc "Michael Rolnik <[email protected]>"
git config --add branch.gdbstub/next.gitpublishcc "Mahmoud Mandour <[email protected]>"
git config --add branch.gdbstub/next.gitpublishcc "Laurent Vivier <[email protected]>"
git config --add branch.gdbstub/next.gitpublishcc [email protected]
git config --add branch.gdbstub/next.gitpublishcc "Marcel Apfelbaum <[email protected]>"
git config --add branch.gdbstub/next.gitpublishcc ""Cédric Le Goater" <[email protected]>"
git config --add branch.gdbstub/next.gitpublishcc [email protected]
git config --add branch.gdbstub/next.gitpublishcc "Song Gao <[email protected]>"
git config --add branch.gdbstub/next.gitpublishcc "Max Filippov <[email protected]>"
git config --add branch.gdbstub/next.gitpublishcc "Palmer Dabbelt <[email protected]>"
git config --add branch.gdbstub/next.gitpublishcc "Marek Vasut <[email protected]>"
git config --add branch.gdbstub/next.gitpublishcc "Bastian Koppelmann <[email protected]>"
#+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 <[email protected]>

---
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 <[email protected]>
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 <[email protected]>
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 <[email protected]>
Using -v is overkill for a script.

Signed-off-by: Alex Bennée <[email protected]>

---
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