From: "W. Trevor King" <wking@tremily.us>
To: meta@public-inbox.org
Cc: "W. Trevor King" <wking@tremily.us>
Subject: [RFC] ssoma-mda: Use the email subject as the commit message
Date: Sat, 18 Oct 2014 13:19:52 -0700 [thread overview]
Message-ID: <af679af8257e250ac606e35a1307ad02907b8426.1413663212.git.wking@tremily.us> (raw)
This is more interesting than just using 'mda' all the time, but it's
harder to setup proper quoting around the message without using
third-party Perl modules (e.g. IPC::Run or String::ShellQuote). This
proof-of-concept patch just assumes the subject doesn't contain
single-quotes ('). This patch also doesn't handle the empty/missing
subject case, which should probably fall back to '<no subject>' or
some such.
I'm fine dropping support for older Gits here, and just using the -m
option to commit-tree. That landed with 96b8d93a (commit-tree: teach
-m/-F options to read logs from elsewhere, 2011-11-09) in Git v1.7.9,
which was released over 2.5 years ago on 2012-01-27.
It would also be useful (I think) to set the GIT_AUTHOR_NAME,
GIT_AUTHOR_EMAIL, and GIT_AUTHOR_DATE environment variables from the
message header before committing. I know how to do that using
Python's subprocess module, but I don't know the Perl incantation.
---
Is there any interest in a Python port of ssoma? The subprocess
handling in Perl's standard libraries is not my favorite ;). I expect
we could handle all of ssoma without leaving Python's standard
libraries. For an example of a related Perl -> Python rewrite that I
just landed, see nmbug [1,2,3].
Cheers,
Trevor
[1]: http://notmuchmail.org/nmbug/
[2]: http://thread.gmane.org/gmane.mail.notmuch.general/19189
id:cover.1412359989.git.wking@tremily.us
[3]: http://article.gmane.org/gmane.mail.notmuch.general/19272
id:2a9f3e7423fe3ab95c2c6fbd6047aed935b6463b.1412703127.git.wking@tremily.us
lib/Ssoma/Git.pm | 5 ++---
lib/Ssoma/MDA.pm | 3 ++-
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/lib/Ssoma/Git.pm b/lib/Ssoma/Git.pm
index 2211893..e8d4cf6 100644
--- a/lib/Ssoma/Git.pm
+++ b/lib/Ssoma/Git.pm
@@ -266,10 +266,9 @@ sub commit_index {
my @cmd = qw/git commit-tree/;
push @cmd, $tree;
push @cmd, '-p', $parent if $parent;
+ push @cmd, '-m', "'$message'";
- # git commit-tree -m didn't work in older git versions
- $message =~ /\A\w+\z/ or die "message must be \\w+ only\n";
- my $commit = $self->qx_sha1("echo $message |". join(' ', @cmd));
+ my $commit = $self->qx_sha1(join(' ', @cmd));
# update the ref
@cmd = (qw/git update-ref/, $ref, $commit);
diff --git a/lib/Ssoma/MDA.pm b/lib/Ssoma/MDA.pm
index 02816a5..6b58b43 100644
--- a/lib/Ssoma/MDA.pm
+++ b/lib/Ssoma/MDA.pm
@@ -102,7 +102,8 @@ sub append {
my $id = $git->simple_to_blob($simple);
$gii->update('100644', $id, $path);
}
- $git->commit_index($gii, 0, $ref, "mda");
+ my $subject = $simple->header("Subject");
+ $git->commit_index($gii, 0, $ref, $subject);
}
# the main entry point takes an Email::Simple object
--
2.1.0.60.g85f0837
next reply other threads:[~2014-10-18 20:19 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-10-18 20:19 W. Trevor King [this message]
2014-10-18 21:04 ` [RFC] ssoma-mda: Use the email subject as the commit message Eric Wong
2014-10-18 21:50 ` W. Trevor King
2014-10-18 23:43 ` Eric Wong
2014-10-19 3:48 ` W. Trevor King
2014-10-19 5:30 ` Eric Wong
2014-10-19 17:31 ` W. Trevor King
2014-10-20 0:49 ` Eric Wong
2014-10-20 15:36 ` W. Trevor King
2014-10-20 19:26 ` Eric Wong
2014-10-20 19:53 ` W. Trevor King
2014-10-26 22:57 ` Eric Wong
2014-10-27 0:19 ` W. Trevor King
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://public-inbox.org/README
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=af679af8257e250ac606e35a1307ad02907b8426.1413663212.git.wking@tremily.us \
--to=wking@tremily.us \
--cc=meta@public-inbox.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://80x24.org/public-inbox.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).