diff --git a/third-party/download-content-shell/download-content-shell.js b/third-party/download-content-shell/download-content-shell.js index 0e2e12014ffe..0ac6d0d7e304 100644 --- a/third-party/download-content-shell/download-content-shell.js +++ b/third-party/download-content-shell/download-content-shell.js @@ -23,7 +23,8 @@ function main() { fs.mkdirSync(CACHE_PATH, {recursive: true}); deleteOldContentShells(); - findPreviousUploadedPosition(findMostRecentChromiumCommit()) + findMostRecentChromiumCommit() + .then(findPreviousUploadedPosition) .then(onUploadedCommitPosition) .catch(onError); @@ -64,13 +65,11 @@ function getPlatform() { throw new Error(`Unrecognized platform detected: ${process.platform}`); } -function findMostRecentChromiumCommit() { - // TODO: this code works only if there is a full chromium checkout present. - // const commitMessage = shell('git log --max-count=1 --grep="Cr-Commit-Position"').toString().trim(); - // const commitPosition = commitMessage.match(/Cr-Commit-Position: refs\/heads\/master@\{#([0-9]+)\}/)[1]; - // return commitPosition; - // TODO: make this dynamic. - return '856956'; +async function findMostRecentChromiumCommit() { + const snapshotUrl = `https://www.googleapis.com/download/storage/v1/b/chromium-browser-snapshots/o/${PLATFORM}%2FLAST_CHANGE?alt=media`; + const commitPosition = await utils.fetch(snapshotUrl); + + return commitPosition.toString(); } function deleteOldContentShells() { diff --git a/third-party/download-content-shell/utils.js b/third-party/download-content-shell/utils.js index 1956851d3cb6..8a23fe4ca5d9 100644 --- a/third-party/download-content-shell/utils.js +++ b/third-party/download-content-shell/utils.js @@ -31,7 +31,7 @@ function fetch(url) { function getCallback(resolve, reject, response) { if (response.statusCode !== 200) { - reject(new Error(`Request error: + ${response.statusCode}`)); + reject(new Error(`Request error: ${response.statusCode}`)); return; } const body = new Stream();