You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by zw...@apache.org on 2017/05/05 19:58:21 UTC

[trafficserver] 01/02: Update changelog.pl to use github instead of Jira

This is an automated email from the ASF dual-hosted git repository.

zwoop pushed a commit to branch 7.1.x
in repository https://gitbox.apache.org/repos/asf/trafficserver.git

commit b989786ff37e0eb975be945e24703b923f49ef79
Author: Phil Sorber <so...@apache.org>
AuthorDate: Thu May 4 15:30:47 2017 -0600

    Update changelog.pl to use github instead of Jira
    
    (cherry picked from commit a68cb22faaed4afcbdd2bddd3cb846add7646b3c)
---
 Makefile.am        |   3 +-
 tools/changelog.pl | 124 +++++++++++++++++++++++++++++------------------------
 2 files changed, 70 insertions(+), 57 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index f1a8747..60bd7da 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -57,8 +57,7 @@ doxygen:
 	@cd doc && $(MAKE) $(AM_MAKEFLAGS) $@
 
 changelog:
-	./tools/changelog.pl $(VERSION) > CHANGELOG-$(VERSION)
-	-git add CHANGELOG-$(VERSION) && git commit -m "Adding CHANGELOG-$(VERSION)"
+	./tools/changelog.pl apache trafficserver $(VERSION) > CHANGELOG-$(VERSION)
 
 asf-dist: asf-distdir
 	tardir=$(distdir) && $(am__tar) --mtime=./configure.ac | bzip2 -9 -c >$(distdir).tar.bz2
diff --git a/tools/changelog.pl b/tools/changelog.pl
index 8ac7fc9..b151a69 100755
--- a/tools/changelog.pl
+++ b/tools/changelog.pl
@@ -22,36 +22,64 @@ use warnings;
 use WWW::Curl::Easy;
 use JSON;
 
-my $fixversion = shift;
-my $url = "https://issues.apache.org/jira";
-my $jql = "project = TS AND status in (Resolved, Closed) AND fixVersion = $fixversion ORDER BY key ASC";
+my $owner = shift;
+my $repo = shift;
+my $milestone = shift;
+my $url = "https://api.github.com";
 
-sub jira_search
+sub milestone_lookup
 {
   my $url = shift;
-  my $jql = shift;
-  my $index = shift;
-  my $endpoint = "/rest/api/2/search";
-
-  my $query = {
-    jql => $jql,
-    startAt => $index,
-    fields => [
-      "summary",
-      "issuetype"
-    ]
-  };
-
-  my $req_body = to_json($query);
+  my $owner = shift;
+  my $repo = shift;
+  my $milestone_title = shift;
+  my $endpoint = "/repos/$owner/$repo/milestones";
+
+  my $params = "state=all";
+
   my $resp_body;
   my $curl = WWW::Curl::Easy->new;
 
-  $curl->setopt(CURLOPT_POST, 1);
-  $curl->setopt(CURLOPT_POSTFIELDS, $req_body);
-  $curl->setopt(CURLOPT_HTTPHEADER, ['Content-Type: application/json']);
-  open(my $fileb, ">", \$resp_body);
-  $curl->setopt(CURLOPT_WRITEDATA, $fileb);
-  $curl->setopt(CURLOPT_URL, $url . $endpoint);
+  #$curl->setopt(CURLOPT_VERBOSE, 1);
+  $curl->setopt(CURLOPT_HTTPHEADER, ['Accept: application/vnd.github.v3+json', 'User-Agent: Awesome-Octocat-App']);
+  $curl->setopt(CURLOPT_WRITEDATA, \$resp_body);
+  $curl->setopt(CURLOPT_URL, $url . $endpoint . '?' . $params);
+
+  my $retcode = $curl->perform();
+  if ($retcode == 0 && $curl->getinfo(CURLINFO_HTTP_CODE) == 200)
+  {
+    my $milestones = from_json($resp_body);
+    foreach my $milestone (@{ $milestones })
+    {
+      if ($milestone->{title} eq $milestone_title)
+      {
+        return $milestone->{number};
+      }
+    }
+  }
+
+  return undef;
+}
+
+sub issue_search
+{
+  my $url = shift;
+  my $owner = shift;
+  my $repo = shift;
+  my $milestone_id = shift;
+  my $page = shift;
+  my $endpoint = "/repos/$owner/$repo/issues";
+
+  my $params = "milestone=$milestone_id&state=closed&page=$page";
+
+  my $resp_body;
+  my $curl = WWW::Curl::Easy->new;
+
+  #$curl->setopt(CURLOPT_VERBOSE, 1);
+  $curl->setopt(CURLOPT_HTTPHEADER, ['Accept: application/vnd.github.v3+json', 'User-Agent: Awesome-Octocat-App']);
+  $curl->setopt(CURLOPT_WRITEDATA, \$resp_body);
+  $curl->setopt(CURLOPT_URL, $url . $endpoint . '?' . $params);
+
   my $retcode = $curl->perform();
   if ($retcode == 0 && $curl->getinfo(CURLINFO_HTTP_CODE) == 200) {
     return from_json($resp_body);
@@ -60,49 +88,35 @@ sub jira_search
   undef;
 }
 
-my $count = 0;
-my $changelog;
-my $issues;
+my $milestone_id = milestone_lookup($url, $owner, $repo, $milestone);
 
-do
+if (!defined($milestone_id))
 {
-  $issues = jira_search($url, $jql, $count);
+  exit 1;
+}
 
-  if (!defined($issues))
-  {
-    exit 1;
-  }
+my $issues;
+my $changelog;
+my $page = 1;
 
-  foreach my $issue (@{ $issues->{issues} })
+do {
+  $issues = issue_search($url, $owner, $repo, $milestone_id, $page);
+  foreach my $issue (@{ $issues })
   {
     if (defined($issue))
     {
-      push @{ $changelog->{$issue->{fields}{issuetype}{name}} }, {key => $issue->{key},  summary => $issue->{fields}{summary}};
-      $count++;
+      push @{ $changelog }, {number => $issue->{number},  title => $issue->{title}};
     }
   }
-}
-while ($count < $issues->{total});
+  $page++;
+} while (scalar @{ $issues });
 
-if (!defined($changelog))
+if (defined($changelog))
 {
-  exit 1;
-}
-
-print "Changes with Apache Traffic Server $fixversion\n";
+  print "Changes with Apache Traffic Server $milestone\n";
 
-foreach my $key (sort keys %{ $changelog })
-{
-  print "\n$key:\n";
-  foreach my $issue (@{ $changelog->{$key} })
+  foreach my $issue (sort {$a->{number} <=> $b->{number}} @{ $changelog })
   {
-    chomp $issue->{summary};
-    $issue->{summary} =~ s/\s+$//; # Trim trailing whitespace
-    print "  *) [$issue->{key}] ";
-    if (length($issue->{summary}) <= (131 - 15)) {
-      print "$issue->{summary}\n";
-    } else {
-      print substr($issue->{summary}, 0, (131 - 18)), "...\n";
-    }
+    print "  #$issue->{number} - $issue->{title}\n";
   }
 }

-- 
To stop receiving notification emails like this one, please contact
"commits@trafficserver.apache.org" <co...@trafficserver.apache.org>.