本文整理匯總了TypeScript中@elastic/nodegit.Clone類的典型用法代碼示例。如果您正苦於以下問題:TypeScript Clone類的具體用法?TypeScript Clone怎麽用?TypeScript Clone使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了Clone類的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: rimraf
rimraf(p, error => {
Git.Clone.clone(url, p, {
fetchOpts: {
callbacks: {
certificateCheck: () => 0,
},
},
}).then(repo => {
resolve(repo);
});
});
示例2: before
before(async () => {
const tmpRepo = path.join(serverOptions.repoPath, 'tmp');
await prepareProject(tmpRepo);
await Git.Clone.clone(`file://${tmpRepo}`, path.join(serverOptions.repoPath, repoUri), {
bare: 1,
fetchOpts: {
callbacks: {
certificateCheck: () => 0,
},
},
});
});
示例3: rimraf
rimraf(path, error => {
console.log(`begin to import ${url} to ${path}`);
Git.Clone.clone(url, path, {
fetchOpts: {
callbacks: {
certificateCheck: () => 0,
},
},
}).then(repo => {
console.log(`import ${url} done`);
resolve(repo);
});
});
示例4: rimraf
rimraf(p, error => {
Git.Clone.clone(url, p, opts).then(repo => {
resolve(repo);
});
});
示例5: doClone
private async doClone(
repo: Repository,
localPath: string,
handler?: CloneProgressHandler,
keyFile?: string
) {
try {
const cbs: RemoteCallbacks = {
transferProgress: {
// Make the progress update less frequent to avoid too many
// concurrently update of git status in elasticsearch.
throttle: 1000,
callback: (stats: any) => {
if (handler) {
const progress =
(100 * (stats.receivedObjects() + stats.indexedObjects())) /
(stats.totalObjects() * 2);
const cloneProgress = {
isCloned: false,
receivedObjects: stats.receivedObjects(),
indexedObjects: stats.indexedObjects(),
totalObjects: stats.totalObjects(),
localObjects: stats.localObjects(),
totalDeltas: stats.totalDeltas(),
indexedDeltas: stats.indexedDeltas(),
receivedBytes: stats.receivedBytes(),
};
handler(progress, cloneProgress);
}
},
} as any,
credentials: this.credentialFunc(keyFile),
};
// Ignore cert check on testing environment.
if (!this.enableGitCertCheck) {
cbs.certificateCheck = () => {
// Ignore cert check failures.
return 0;
};
}
const gitRepo = await Git.Clone.clone(repo.url, localPath, {
bare: 1,
fetchOpts: {
callbacks: cbs,
},
});
const headCommit = await gitRepo.getHeadCommit();
const headRevision = headCommit.sha();
const currentBranch = await gitRepo.getCurrentBranch();
const currentBranchName = currentBranch.shorthand();
this.log.info(
`Clone repository from ${
repo.url
} done with head revision ${headRevision} and default branch ${currentBranchName}`
);
return {
uri: repo.uri,
repo: {
...repo,
defaultBranch: currentBranchName,
revision: headRevision,
},
};
} catch (error) {
if (error.message && error.message.startsWith(SSH_AUTH_ERROR.message)) {
throw SSH_AUTH_ERROR;
} else {
const msg = `Clone repository from ${repo.url} error.`;
this.log.error(msg);
this.log.error(error);
throw new Error(error.message);
}
}
}