Improve common landings tool to easily generate a pushlog. Fixes #33

This commit is contained in:
Marco Castelluccio 2017-01-30 13:22:27 +00:00
Родитель 68e79b43d7
Коммит 8f3e5232ec
2 изменённых файлов: 107 добавлений и 11 удалений

Просмотреть файл

@ -6,13 +6,40 @@
</head>
<body>
<script src="common_landings.js" type="text/javascript"></script>
<p>Insert one or more links like <code>https://hg.mozilla.org/releases/mozilla-beta/pushloghtml?fromchange=FIREFOX_51_0b13_RELEASE&tochange=FIREFOX_51_0b14_RELEASE</code></p>
<input type="text" name="pushloglink1" id="pushloglink1" size="140" placeholder="First pushloghtml link...">
<br>
<input type="text" name="pushloglink2" id="pushloglink2" size="140" placeholder="Second pushloghtml link...">
<br>
<input type="text" name="pushloglink3" id="pushloglink3" size="140" placeholder="Third pushloghtml link...">
<h2>Pushlog/regression range generator</h2>
<br><br>
<h3>Nightly</h3>
<input type="text" name="nightly_first_affected" id="nightly_first_affected" placeholder="Build ID or changeset">
<select name="nightly_days" id="nightly_days">
<option selected>one day</option>
<option>two days</option>
<option>three days</option>
<option>a week</option>
</select>
<br>
<a id="nightly_pushloglink"></a>
<br><br>
<h3>Aurora</h3>
<input type="text" name="aurora_first_affected" id="aurora_first_affected" placeholder="Build ID or changeset">
<select name="aurora_days" id="aurora_days">
<option selected>one day</option>
<option>two days</option>
<option>three days</option>
<option>a week</option>
</select>
<br>
<a id="aurora_pushloglink"></a>
<br><br>
<h3>Beta</h3>
<input type="text" name="beta_first_affected" id="beta_first_affected" placeholder="Version number (e.g. 51.0b9)">
<select name="beta_builds" id="beta_builds">
<option selected>one build</option>
<option>two builds</option>
<option>three builds</option>
</select>
<br>
<a id="beta_pushloglink"></a>
<br><br><br><br>
<button id="getCommonLandings">Find common landings</button>
<br><br>
<div id="results"></div>

Просмотреть файл

@ -2,16 +2,85 @@ let onLoad = new Promise(function(resolve, reject) {
window.onload = resolve;
});
function dropdownDateToHGMODate(val) {
if (val === 'one day') {
return '1+day+ago';
} else if (val === 'two days') {
return '2+days+ago';
} else if (val === 'three days') {
return '3+days+ago';
} else if (val === 'a week') {
return '1+week+ago';
}
throw new Exception('Unknown value ' + val);
}
function dropdownBuildToVal(val) {
if (val === 'one build') {
return 1;
} else if (val === 'two builds') {
return 2;
} else if (val === 'three builds') {
return 3;
}
throw new Exception('Unknown value ' + val);
}
function betaBuildToTag(val) {
return 'FIREFOX_' + val.replace('.', '_') + '_RELEASE';
}
function subtractFromBetaBuild(version, val) {
let major = version.substring(0, version.indexOf('b'));
let betaBuild = version.substring(version.indexOf('b') + 1);
return major + 'b' + (Number(betaBuild) - val);
}
function getCommonLandings() {
let pushlog_links = [];
for (let i = 1; i < 4; i++) {
let pushlog_link = document.getElementById('pushloglink' + i).value;
if (pushlog_link) {
pushlog_links.push(pushlog_link);
}
// Nightly
let nightlyFirstAffected = document.getElementById('nightly_first_affected').value;
if (nightlyFirstAffected) {
let nightlyStartDateElem = document.getElementById('nightly_days');
let nightlyStartDate = dropdownDateToHGMODate(nightlyStartDateElem.options[nightlyStartDateElem.selectedIndex].value);
let nightlyPushlogLink = 'https://hg.mozilla.org/mozilla-central/pushloghtml?startdate=' + nightlyStartDate + '&tochange=' + nightlyFirstAffected;
let nightlyPushlogLinkElem = document.getElementById('nightly_pushloglink');
nightlyPushlogLinkElem.textContent = nightlyPushlogLinkElem.href = nightlyPushlogLink;
pushlog_links.push(nightlyPushlogLink);
}
// Aurora
let auroraFirstAffected = document.getElementById('aurora_first_affected').value;
if (auroraFirstAffected) {
let auroraStartDateElem = document.getElementById('aurora_days');
let auroraStartDate = dropdownDateToHGMODate(auroraStartDateElem.options[auroraStartDateElem.selectedIndex].value);
let auroraPushlogLink = 'https://hg.mozilla.org/releases/mozilla-aurora/pushloghtml?startdate=' + auroraStartDate + '&tochange=' + auroraFirstAffected;
let auroraPushlogLinkElem = document.getElementById('aurora_pushloglink');
auroraPushlogLinkElem.textContent = auroraPushlogLinkElem.href = auroraPushlogLink;
pushlog_links.push(auroraPushlogLink);
}
// Beta
let betaFirstAffected = document.getElementById('beta_first_affected').value;
if (betaFirstAffected) {
let betaStartBuildElem = document.getElementById('beta_builds');
let betaStartBuild = subtractFromBetaBuild(betaFirstAffected, dropdownBuildToVal(betaStartBuildElem.options[betaStartBuildElem.selectedIndex].value));
let betaPushlogLink = 'https://hg.mozilla.org/releases/mozilla-beta/pushloghtml?fromchange=' + betaBuildToTag(betaStartBuild) + '&tochange=' + betaBuildToTag(betaFirstAffected);
let betaPushlogLinkElem = document.getElementById('beta_pushloglink');
betaPushlogLinkElem.textContent = betaPushlogLinkElem.href = betaPushlogLink;
pushlog_links.push(betaPushlogLink);
}
return Promise.all(
pushlog_links
.map(link =>