Skip to content

Commit 057785c

Browse files
committed
bump-version: look only at the latest release
The API call reporting the latest release does not, in fact, return pre-releases as feared by this maintainer, but it really reports the latest official release. Since we are only interested in the latest release for auto-bumping, and since the full release list is much larger, let's switch to this API call. Note: as that API call returns a single release, not an array of releases, we lose one level of indentation, and the diff is best viewed with the -w option. Suggested by Kenn Herman. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
1 parent 89f55e7 commit 057785c

1 file changed

Lines changed: 12 additions & 14 deletions

File tree

bump-version.js

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -47,26 +47,24 @@ var autoUpdate = function() {
4747
};
4848

4949
var determineVersion = function(body) {
50-
var releases = JSON.parse(body),
50+
var release = JSON.parse(body),
5151
versionRegex = /^v(\d+\.\d+\.\d+(\.\d+)?)\.windows\.(\d+)/,
5252
timeRegex = /^(\d+)-(\d+)-(\d+)T(\d+):(\d+):(\d+)Z$/,
5353
version = false,
5454
match, latest, url;
5555

56-
for (var i = 0; i < releases.length && !version; i++) {
57-
if (match = releases[i].tag_name.match(versionRegex)) {
58-
version = match[1];
56+
if (match = release.tag_name.match(versionRegex)) {
57+
version = match[1];
5958

60-
if (parseInt(match[3]) > 1) {
61-
version += '(' + match[3] + ')';
62-
}
59+
if (parseInt(match[3]) > 1) {
60+
version += '(' + match[3] + ')';
61+
}
6362

64-
match = releases[i].published_at.match(timeRegex);
65-
latest = new Date(match[1], match[2] - 1, match[3],
66-
match[4], match[5], match[6], 0).toUTCString();
67-
latest = latest.replace(/GMT$/, 'UTC');
68-
url = releases[i].html_url;
69-
}
63+
match = release.published_at.match(timeRegex);
64+
latest = new Date(match[1], match[2] - 1, match[3],
65+
match[4], match[5], match[6], 0).toUTCString();
66+
latest = latest.replace(/GMT$/, 'UTC');
67+
url = release.html_url;
7068
}
7169

7270
process.stderr.write('Auto-detected version ' + version
@@ -78,7 +76,7 @@ var autoUpdate = function() {
7876
https.body = '';
7977
https.get({
8078
'hostname': 'api.github.com',
81-
'path': '/repos/git-for-windows/git/releases',
79+
'path': '/repos/git-for-windows/git/releases/latest',
8280
'headers': {
8381
'User-Agent': 'Git for Windows version updater'
8482
}

0 commit comments

Comments
 (0)