summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteve Frécinaux <code@istique.net>2007-07-19 12:06:19 (GMT)
committerSteve Frécinaux <code@istique.net>2007-07-19 12:06:19 (GMT)
commit58ffa65dc1751a249a54daac0c4509841b61f47b (patch)
tree2b9d2c3f27b97b496f3d0451801320d1c77e4dc9
parent816500f7aad3c75754863c1c58c69917dc040dfa (diff)
downloadgit-bugzilla-58ffa65dc1751a249a54daac0c4509841b61f47b.tar.gz
git-bugzilla-58ffa65dc1751a249a54daac0c4509841b61f47b.tar.xz
Split out the reading of the patch information
-rwxr-xr-xgit-send-bugzilla.pl40
1 files changed, 23 insertions, 17 deletions
diff --git a/git-send-bugzilla.pl b/git-send-bugzilla.pl
index 66e58c7..2c7f89d 100755
--- a/git-send-bugzilla.pl
+++ b/git-send-bugzilla.pl
@@ -49,6 +49,27 @@ sub authenticate {
die "Invalid login or password\n" if $mech->title =~ /Invalid/i;
}
+sub get_patch_info {
+ my $rev = shift;
+
+ open COMMIT, '-|', "git-cat-file commit $rev";
+ # skip headers
+ while (<COMMIT>) {
+ chop;
+ last if $_ eq '';
+ }
+ chop (my $description = <COMMIT>);
+ chop (my $comment = join '', <COMMIT>) unless eof COMMIT;
+ close COMMIT;
+
+ $comment .= "\n---\n" unless $comment eq '';
+ $comment .= `git-diff-tree --stat --no-commit-id $rev`;
+
+ my $patch = `git-diff-tree -p $rev`;
+
+ return ($description, $comment, $patch);
+}
+
sub add_attachment {
my $bugid = shift;
my $patch = shift;
@@ -156,23 +177,8 @@ print STDERR "Attaching patches...\n";
my $i = $start_number;
my $n = @revisions - 1 + $i;
for my $rev (@revisions) {
- my $description = $numbered ? "[$i/$n]" : '[PATCH]';
- my $comment = '';
-
- open COMMIT, '-|', "git-cat-file commit $rev";
- # skip headers
- while (<COMMIT>) {
- chop;
- last if $_ eq "";
- }
- chop ($description .= ' ' . <COMMIT>);
- chop ($comment = join "", <COMMIT>) unless eof COMMIT;
- close COMMIT;
-
- $comment .= "\n---\n" unless $comment eq '';
- $comment .= `git-diff-tree --stat --no-commit-id $rev`;
- my $patch = `git-diff-tree -p $rev`;
-
+ my ($description, $comment, $patch) = get_patch_info $rev;
+ $description = ($numbered ? "[$i/$n]" : '[PATCH]') . " $description";
print STDERR " - $description\n";
add_attachment $bugid, $patch, $description, $comment unless $dry_run;