apex-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From an...@apache.org
Subject incubator-apex-site git commit: fix gulp fetch-versions task
Date Fri, 13 Nov 2015 20:30:30 GMT
Repository: incubator-apex-site
Updated Branches:
  refs/heads/master 90b0863c7 -> 2670a8a1c


fix gulp fetch-versions task


Project: http://git-wip-us.apache.org/repos/asf/incubator-apex-site/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-apex-site/commit/2670a8a1
Tree: http://git-wip-us.apache.org/repos/asf/incubator-apex-site/tree/2670a8a1
Diff: http://git-wip-us.apache.org/repos/asf/incubator-apex-site/diff/2670a8a1

Branch: refs/heads/master
Commit: 2670a8a1c9adc4d306507b517e576cbc8eb65214
Parents: 90b0863
Author: Andy Perlitch <andy@datatorrent.com>
Authored: Fri Nov 13 12:30:26 2015 -0800
Committer: Andy Perlitch <andy@datatorrent.com>
Committed: Fri Nov 13 12:30:26 2015 -0800

----------------------------------------------------------------------
 gulpfile.js   | 45 ++++++++++++++++++++++++++++-----------------
 releases.json |  4 ++--
 2 files changed, 30 insertions(+), 19 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-apex-site/blob/2670a8a1/gulpfile.js
----------------------------------------------------------------------
diff --git a/gulpfile.js b/gulpfile.js
index 7a1d122..5361bf5 100644
--- a/gulpfile.js
+++ b/gulpfile.js
@@ -11,6 +11,7 @@ var jsdom = require('jsdom');
 var fs = require('fs');
 var async = require('async');
 var _ = require('lodash');
+var exec = require('child_process').exec;
 
 // Constants
 var TEMP_PARTIAL_LOCATION = './.tmp/partials/';
@@ -167,25 +168,35 @@ gulp.task('fetch-versions', function(taskCb) {
           async.each(releases, function(release, eachCb) {
 
             // Get the tags for the repo
-            request({
-              url: 'https://api.github.com/repos/apache/' + release.repo + '/tags',
-              json: true,
-              headers: { 'User-Agent': 'apache' } // Github asks that the user agent is the
GH org or username
-            }, function(err, response) {
-
-              // Abort if tags not found or something happened with github API
-              if (err) {
-                return eachCb(err);
+            var gitCommand = 'git ls-remote --tags "git://git.apache.org/' + release.repo
+ '.git"';
+            exec(gitCommand, function(err, stdout, stderr) {
+
+              // Abort if tags not found or something bad happened with the git ls-remote
command
+              if (err || stderr) {
+                return eachCb(err || stderr);
+              }
+
+              // Lines from ls-remote command look like [COMMIT_HASH]\trefs/tags/[TAG_NAME]
+              var lines = stdout.split('\n');
+              var tagHash;
+
+              // Find hash for this release's tag
+              for (var i = 0; i < lines.length; i++) {
+                var parts = lines[i].split('\t');
+                if (parts[1].replace(/^refs\/tags\/v?/, '') === release.version) {
+                  tagHash = parts[0];
+                  break;
+                }
+              }
+
+              // Ensure we found one
+              if (!tagHash) {
+                return eachCb('Could not find tag from ls-remote command');
               }
-              
-              // Find the tag object corresponding to this release
-              var ghTag = _.find(response.body, function(t) {
-                return t.name.replace(/^v/, '') === release.version;
-              });
 
-              // Get info about the commit that the tag points to
+              // Get info about the tag via its hash (found with the ls-remote command)
               request({
-                url: ghTag.commit.url, // Github API address
+                url: 'https://api.github.com/repos/apache/' + release.repo + '/git/tags/'
+ tagHash, // Github API address
                 json: true,
                 headers: { 'User-Agent': 'apache' }
               }, function(err, response) {
@@ -196,7 +207,7 @@ gulp.task('fetch-versions', function(taskCb) {
                 }
 
                 // Set the date from the this information
-                release.date = Date.parse(response.body.commit.author.date);
+                release.date = Date.parse(response.body.tagger.date);
 
                 // We're all done
                 eachCb();

http://git-wip-us.apache.org/repos/asf/incubator-apex-site/blob/2670a8a1/releases.json
----------------------------------------------------------------------
diff --git a/releases.json b/releases.json
index 1a4751a..15fad44 100644
--- a/releases.json
+++ b/releases.json
@@ -3,8 +3,8 @@
     "src": [
       {
         "version": "3.2.0-incubating",
-        "date": 1445639866000,
-        "repo": "incubator-apex-core"
+        "repo": "incubator-apex-core",
+        "date": 1446268713000
       }
     ]
   },


Mime
View raw message