Skip to content

Commit

Permalink
Try expanding short SHAs
Browse files Browse the repository at this point in the history
  • Loading branch information
ockham committed Feb 4, 2021
1 parent d0a7874 commit 16070b0
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions packages/env/lib/download-sources.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,9 @@ async function downloadGitSource( source, { onProgress, spinner, debug } ) {

log( 'Fetching the specified ref.' );
const remote = await repository.getRemote( 'origin' );
await remote.fetch( source.ref, gitFetchOptions.fetchOpts );
const oid = NodeGit.Oid.fromString( source.ref );
const ref = NodeGit.Commit.lookupPrefix( repository, oid, 6 );
await remote.fetch( ref, gitFetchOptions.fetchOpts );
await remote.disconnect();
try {
log( 'Checking out the specified ref.' );
Expand All @@ -151,16 +153,14 @@ async function downloadGitSource( source, { onProgress, spinner, debug } ) {
.getReference( 'FETCH_HEAD' )
// Sometimes git doesn't update FETCH_HEAD for things
// like tags so we try another method here.
.catch(
repository.getReference.bind( repository, source.ref )
),
.catch( repository.getReference.bind( repository, ref ) ),
{
checkoutStrategy: NodeGit.Checkout.STRATEGY.FORCE,
}
);
} catch ( error ) {
log( 'Ref needs to be set as detached.' );
await repository.setHeadDetached( source.ref );
await repository.setHeadDetached( ref );
}

onProgress( 1 );
Expand Down

0 comments on commit 16070b0

Please sign in to comment.