From 308e7fe5486ff1959dcad4d25a5e85dfb083fb4a Mon Sep 17 00:00:00 2001 From: Yavor Georgiev Date: Thu, 12 Oct 2017 19:19:06 +0200 Subject: [PATCH] fix download-realm to account for lightweight tags --- scripts/download-realm.js | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/scripts/download-realm.js b/scripts/download-realm.js index 9b282c79..c50564a4 100644 --- a/scripts/download-realm.js +++ b/scripts/download-realm.js @@ -33,7 +33,7 @@ function exec() { if (error) { reject(error); } else { - resolve(stdout); + resolve(stdout.trim()); } } args.push(callback); @@ -145,6 +145,17 @@ function acquireCore(options, dependencies, target) { .then(() => extract(downloadedArchive, target, archiveRootFolder)); } +function getSyncCommitSha(version) { + return exec(`git ls-remote git@github.com:realm/realm-sync.git --tags "v${version}^{}"`) + .then(stdout => { + if (!Boolean(stdout)) { + return exec(`git ls-remote git@github.com:realm/realm-sync.git --tags "v${version}"`) + } else { + return stdout; + } + }).then(stdout => /([^\t]+)/.exec(stdout)[0]); +} + function acquireSync(options, dependencies, target) { let serverFolder = 'sync'; let flavor = options.debug ? 'Debug' : 'Release'; @@ -162,8 +173,7 @@ function acquireSync(options, dependencies, target) { break; case 'win': promise = acquireCore(options, dependencies, target) - .then(() => exec(`git ls-remote git@github.com:realm/realm-sync.git --tags "v${dependencies.REALM_SYNC_VERSION}^{}"`)) - .then(stdout => /([^\t]+)/.exec(stdout)[0]) + .then(() => getSyncCommitSha(dependencies.REALM_SYNC_VERSION)) .then(sha => serverFolder += `/sha-version/${sha}`); const arch = options.arch === 'ia32' ? 'Win32' : options.arch; archive = `realm-sync-${flavor}-v${dependencies.REALM_SYNC_VERSION}-Windows-${arch}-devel.tar.gz`;