本文整理匯總了TypeScript中atom.GitRepository.default方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript GitRepository.default方法的具體用法?TypeScript GitRepository.default怎麽用?TypeScript GitRepository.default使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類atom.GitRepository
的用法示例。
在下文中一共展示了GitRepository.default方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: getRepoForDirectory
export const getRepoForPath = async (path: string) => {
const repo = getCachedRepo(path);
if (repo) return repo;
const stat = fs.statSync(path);
const directory = new Directory(stat.isFile() ? Path.dirname(path) : path);
return await getRepoForDirectory(directory);
};
示例2: getRepo
export async function getRepo(): Promise<GitRepository | undefined> {
const activeEditor = atom.workspace.getCenter().getActiveTextEditor();
if (activeEditor) {
const path = activeEditor.getPath();
if (path) {
let repo = getCachedRepo(path);
if (repo) return repo;
const directory = new File(path).getParent();
repo = await getRepoForDirectory(directory);
if (repo) return repo;
}
}
const repos: GitRepository[] = (await Promise.all(
atom.project.getDirectories().map(getRepoForDirectory)
).then(results => results.filter(Boolean))) as GitRepository[];
if (repos.length === 0) return undefined;
if (repos.length === 1) return repos[0];
if (repos.length > 1) return chooseRepo(repos);
}