From bb006cd71e4f9a662c589bcf7f4440f279311ab2 Mon Sep 17 00:00:00 2001 From: Marco Castelluccio Date: Mon, 30 Jan 2017 13:59:42 +0000 Subject: [PATCH] Support getting changeset from build ID of a Aurora build --- buildid_changeset.js | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/buildid_changeset.js b/buildid_changeset.js index c066775b..a70ca16a 100644 --- a/buildid_changeset.js +++ b/buildid_changeset.js @@ -60,19 +60,29 @@ function toTwoDigits(num) { return num; } -function fromBuildIDtoChangeset(buildID) { +function fromBuildIDtoChangeset(buildID, channel='nightly') { let buildObj = parseBuildID(buildID); - let directory = 'https://ftp.mozilla.org/pub/firefox/nightly/' + buildObj.year + '/' + toTwoDigits(buildObj.month) + '/' + buildObj.year + '-' + toTwoDigits(buildObj.month) + '-' + toTwoDigits(buildObj.day) + '-' + toTwoDigits(buildObj.hour) + '-' + toTwoDigits(buildObj.minute) + '-' + toTwoDigits(buildObj.second) + '-mozilla-central/'; + let dirEnd; + if (channel === 'nightly') { + dirEnd = 'central'; + } else if (channel === 'aurora') { + dirEnd = 'aurora'; + } + + let directory = 'https://ftp.mozilla.org/pub/firefox/nightly/' + buildObj.year + '/' + toTwoDigits(buildObj.month) + '/' + buildObj.year + '-' + toTwoDigits(buildObj.month) + '-' + toTwoDigits(buildObj.day) + '-' + toTwoDigits(buildObj.hour) + '-' + toTwoDigits(buildObj.minute) + '-' + toTwoDigits(buildObj.second) + '-mozilla-' + dirEnd + '/'; return fetch(directory) .then(response => response.text()) .then(data => { - let file = data.match(/firefox-\d+.0a1.en-US.win32.txt/); - if (file.length == 1) { + let file = data.match(/firefox-\d+.0a[12].en-US.win32.txt/); + if (!file) { + file = data.match(/firefox-\d+.0a[12].en-US.linux-x86_64.txt/) + } + if (file && file.length == 1) { return file[0]; } else { - throw new Error('Couldn\'t find win32.txt file.'); + throw new Error('Couldn\'t find *.win32.txt or *.linux-x86_64.txt file.'); } }) .then(file => fetch(directory + file)) @@ -88,8 +98,13 @@ function fromBuildIDtoChangeset(buildID) { }); } -function getRevFromChangeset(changeset) { - let re = /https:\/\/hg.mozilla.org\/mozilla-central\/rev\/([A-Za-z0-9]+)/; +function getRevFromChangeset(changeset, channel='nightly') { + let re; + if (channel === 'nightly') { + re = /https:\/\/hg.mozilla.org\/mozilla-central\/rev\/([A-Za-z0-9]+)/; + } else if (channel === 'aurora') { + re = /https:\/\/hg.mozilla.org\/releases\/mozilla-aurora\/rev\/([A-Za-z0-9]+)/; + } let result = re.exec(changeset); return result[1]; }