本文整理汇总了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);
}
}
}