Tags 462758 patch
thanks
Hi,
On Sun, 27 Jan 2008 12:03:52 +0100, Patrick Schoenfeld wrote:
> I'm working on implementing this and will add a patch as soon as I'm
> ready.
a promise is a promise, so here is the patch. Its generated by svn diff
against the current svn snapshot (with my changes applied). It adds an
option -e (--edit) which will launch an editor via sensible-editor in
order to edit a commit message before committing it. If called with
debcommit -C -e it will be editted before confirm message is shown.
I would feel lucky if this could be committed in the svn repository.
Thanks and best Regards,
Patrick
Index: debian/changelog
===================================================================
--- debian/changelog (Revision 911)
+++ debian/changelog (Arbeitskopie)
@@ -17,8 +17,12 @@
[ Mohammed Adnène Trojette ]
* debcheckout: remove "-d" from Vcs-Cvs: field if a maintainer puts it.
- -- Adam D. Barratt <[EMAIL PROTECTED]> Sat, 26 Jan 2008 15:45:32 +0000
+ [ Patrick Schoenfeld ]
+ * debcommit: implemented edit functionality so that commit messages can be
+ altered before committing
+ -- Patrick Schoenfeld <[EMAIL PROTECTED]> Sun, 27 Jan 2008 10:48:45 +0100
+
devscripts (2.10.13) unstable; urgency=low
* The 'we sponsor Adam for DM' upload
Index: scripts/debcommit.pl
===================================================================
--- scripts/debcommit.pl (Revision 911)
+++ scripts/debcommit.pl (Arbeitskopie)
@@ -6,7 +6,7 @@
=head1 SYNOPSIS
-B<debcommit> [B<--release>] [B<--message=>I<text>] [B<--noact>] [B<--confirm>] [B<--changelog=>I<path>] [B<--all> | I<files to commit>]
+B<debcommit> [B<--release>] [B<--message=>I<text>] [B<--noact>] [B<--confirm>] [B<--edit>] [B<--changelog=>I<path>] [B<--all> | I<files to commit>]
=head1 DESCRIPTION
@@ -49,6 +49,11 @@
Display the generated commit message and ask for confirmation before committing
it.
+=item B<-e> B<--edit>
+
+Edit the generated commit message in your favorite editor before committing
+it.
+
=item B<-a> B<--all>
Commit all files. This is the default operation when using a VCS other
@@ -109,6 +114,7 @@
use Getopt::Long;
use Cwd;
use File::Basename;
+use File::Temp;
my $progname = basename($0);
my $modified_conf_msg;
@@ -123,11 +129,12 @@
and commit the change to a package\'s repository.
Options:
- -c --changelog=path Specify the location of the changelog
+ -c --changelog=path Specify the location of the changelog
-r --release Commit a release of the package and create a tag
-m --message=text Specify a commit message
-n --noact Dry run, no actual commits
-C --confirm Ask for confirmation of the message before commit
+ -e --edit Edit the message in EDITOR before commit
-a --all Commit all files (default except for git)
-s --strip-message Strip the leading '* ' from the commit message
--no-strip-message Do not strip a leading '* ' (default)
@@ -160,6 +167,7 @@
my $message;
my $noact=0;
my $confirm=0;
+my $edit=0;
my $all=0;
my $stripmessage=0;
my $signtags=0;
@@ -223,6 +231,7 @@
"m|message=s" => \$message,
"n|noact" => \$noact,
"C|confirm" => \$confirm,
+ "e|edit" => \$edit,
"a|all" => \$all,
"c|changelog=s" => \$changelog,
"s|strip-message!" => \$stripmessage,
@@ -230,7 +239,7 @@
"h|help" => sub { usage(); exit 0; },
"v|version" => sub { version(); exit 0; },
)) {
- die "Usage: debcommit [--release] [--message=text] [--noact] [--confirm] [--changelog=path] [--all | files to commit]\n";
+ die "Usage: debcommit [--release] [--message=text] [--noact] [--confirm] [--edit] [--changelog=path] [--all | files to commit]\n";
}
my @files_to_commit = @ARGV;
@@ -260,6 +269,10 @@
}
else {
$message=getmessage() if ! defined $message;
+
+ if ($edit) {
+ $message = edit($message);
+ }
commit($message) if not $confirm or confirm($message);
}
@@ -321,7 +334,7 @@
sub commit {
my $message=shift;
-
+
die "debcommit: can't specify a list of files to commit when using --all\n"
if (@files_to_commit and $all);
@@ -524,6 +537,23 @@
}
}
+sub edit {
+ my $message=shift;
+ my $tempfile=".commit-tmp";
+ open(FH, ">$tempfile") || die "debcommit: unable to create a temporary file.\n";
+ print FH $message;
+ close(FH);
+ system("sensible-editor $tempfile");
+ open(FH, "<$tempfile") || die "debcommit: unable to open temporary file for reading\n";
+ $message = "";
+ while(<FH>)
+ {
+ $message .= $_;
+ }
+ close(FH);
+ unlink($tempfile);
+ return($message);
+}
=head1 LICENSE
This code is copyright by Joey Hess <[EMAIL PROTECTED]>, all rights reserved.