Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
oid = await isogit.expandOid({ gitdir, oid });
}
obj = await isogit.readObject({ gitdir, oid, format: 'parsed' });
} catch (e) {
// expandOid or readObject failed
}
}
// test if it is a reference
if (!obj) {
try {
// try local branches or tags
oid = await isogit.resolveRef({ gitdir, ref, depth: 10 });
} catch (e) {
// try remote branches
try {
oid = await isogit.resolveRef({ gitdir, ref: `origin/${ref}`, depth: 10 });
} catch (e1) {
// no match
}
}
if (oid) {
obj = await isogit.readObject({ gitdir, oid, format: 'parsed' });
}
}
if (obj) {
if (obj.type === 'commit') {
const commit = obj.object as isogit.CommitDescription;
return {
id: obj.oid,
author: commit.author.name,
committer: commit.committer.name,
message: commit.message,
async function getBranchCommit (refspec) {
const repo = await getRepo();
return git.resolveRef({ ...repo, ref: refspec });
}
async resolveRef(ref: string): Promise {
try {
const commitSha = await resolveRef({
dir: this.projectDir,
ref: ref
});
return commitSha;
} catch(err) {
return null;
}
}
public async getDefaultBranch(uri: RepositoryUri): Promise {
const gitdir = this.repoDir(uri);
const ref = await isogit.resolveRef({ gitdir, ref: HEAD, depth: 2 });
if (ref.startsWith(REFS_HEADS)) {
return ref.substr(REFS_HEADS.length);
}
return ref;
}
static async getCurrentRevision(dir) {
return git.resolveRef({ dir, ref: 'HEAD' });
}
dir: filepath.substring(0, filepath.lastIndexOf("/"))
};
if (
!fs.existsSync(
filepath.substring(0, filepath.lastIndexOf("/")) + "/.git/"
)
) {
return of(
actions.gitListBranchFailed({
error: new Error("no notebook loaded to list currentBranch"),
contentRef: action.payload.contentRef
})
);
}
return from(git.resolveRef({ ...repo, ref: "HEAD", depth: 1 })).pipe(
map(currentBranch =>
actions.gitListBranchSuccessful({
currentBranch: currentBranch.substring(
currentBranch.lastIndexOf("/") + 1,
currentBranch.length
)
})
),
catchError(err => actions.gitListBranchFailed(err))
);
})
);
public async getHeadRevision(uri: RepositoryUri): Promise {
const gitdir = this.repoDir(uri);
return await isogit.resolveRef({ gitdir, ref: HEAD, depth: 10 });
}