summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTzafrir Cohen <tzafrir@cohens.org.il>2010-04-24 12:38:17 +0300
committerTzafrir Cohen <tzafrir@cohens.org.il>2010-04-24 12:38:17 +0300
commitcbbf98c40787e3e5ee7c8a2f8d440031713db6a6 (patch)
tree0245b13054c03735cc50595da040732e5dc029fb
parent4a3c947ee2e3b5a280d1d44eaff229256a9fd55f (diff)
default to last diff again
* Revert the default to using last diff rather than first * A few more bug fixes
-rwxr-xr-xrb-patch45
1 files changed, 30 insertions, 15 deletions
diff --git a/rb-patch b/rb-patch
index 96dbae1..80091c3 100755
--- a/rb-patch
+++ b/rb-patch
@@ -8,7 +8,6 @@ use Pod::Usage;
use Digest::SHA1 qw /sha1_hex/;
my %opt = (
- diff_num => 1,
);
GetOptions(
@@ -25,13 +24,20 @@ if (not defined $opt{review_num}) {
pod2usage(-exitstatus => 0, -verbose => 2) if $opt{man};
-my $BASE_URL="https://reviewboard.asterisk.org";
-
+my $reviewboard_server ="reviewboard.asterisk.org";
+my $base_url="https://reviewboard.asterisk.org";
+my $diff_num;
+my $diff_num_str = "";
+if (defined $opt{diff_num}) {
+ $diff_num = $opt{diff_num};
+ print STDERR "$diff_num\n";
+ $diff_num_str = "/$diff_num";
+ exit 1;
+}
my $review_num = $opt{review_num};
-my $diff_num = $opt{diff_num};
-my $review_url = "$BASE_URL/r/$review_num";
-my $diff_page_url = "$review_url/diff/$diff_num";
+my $review_url = "$base_url/r/$review_num";
+my $diff_page_url = "$review_url/diff$diff_num_str";
my $diff_url = "$diff_page_url/raw";
my $content = get($diff_page_url);
@@ -41,11 +47,12 @@ die "$0: Failed to get reviewboard page $diff_page_url\n" unless defined $conten
my @page = split(/\n/, $content);
$content =~ m{<h1 id="summary" class="editable">([^<]*)</h1>};
my $summary = $1;
-$content =~ m{<a id="submitter" href="([^"]*)">([^<]*)</a>};
-my ($url, $name) = ($1, $2);
-$content =~ m{<span id="branch" class="editable">([^<]*)</a>};
+$content =~ m{<a id="submitter" href="[^"]*">([^<]*)</a>};
+my $name = $1;
+$content =~ m{<span id="branch" class="editable">([^<]*)</span>};
my $branch = $1;
-$url = "$BASE_URL$url";
+$content =~ m{var gRevision = '(\d+)';};
+$diff_num = $1;
my $ua = LWP::UserAgent->new;
my $response = $ua->get($diff_url);
@@ -56,7 +63,7 @@ die "$0: Failed to get raw diff $diff_url".($response->status_live)."\n"
my $raw_diff = $response->content;
my $date = $response->header('Date');
-my $checksum = sha1_hex("$review_num::$diff_num::$name::$date");
+my $checksum = sha1_hex("${review_num}::${diff_num}::${name}::{$date}");
#my @head = head($diff_page_url);
##my $date = $head[2];
#my $date = join '>|<', @head;
@@ -70,12 +77,15 @@ $raw_diff =~ s{\n\+\+\+ }{$&b/}g;
print
"From $checksum $date
-From: $name <$url>
+From: $name <$name\@$reviewboard_server>
Date: $date
Subject: [PATCH] $summary
-Review No. $review_num. diff no. $diff_num.
-Base branch: $branch, revision: $revision
+Review: $review_num
+Diff: $diff_num
+Svn-Branch: $branch
+Svn-Revision: $revision
+Origin: $diff_page_url
<fill in further description>
@@ -95,7 +105,8 @@ rb-patch
rb-patch -r I<NUM>
Options:
- -r --review number of reivewboard review to fetch. Required.
+ -r --review number of reivewboard review to fetch. Required.
+ -d --diff number of the diff to fetch. Default: last one.
--help brief help message
--man full documentation
@@ -107,6 +118,10 @@ Options:
Fetch ReviewBoard review number I<num>. This parameter is required.
+=item B<--diff> I<num>
+
+Fetch diff no. I<num> rather than the last one.
+
=item B<--help>
Print a brief help message and exits.