本文整理匯總了TypeScript中atom.GitRepository.getWorkingDirectory方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript GitRepository.getWorkingDirectory方法的具體用法?TypeScript GitRepository.getWorkingDirectory怎麽用?TypeScript GitRepository.getWorkingDirectory使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類atom.GitRepository
的用法示例。
在下文中一共展示了GitRepository.getWorkingDirectory方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: isPathStaged
async isPathStaged(path: string): Promise<boolean> {
const result = await git(["diff", "--cached", "--name-only", path], {
cwd: this.repo.getWorkingDirectory()
});
if (path === this.getWorkingDirectory() && result.output !== "") return true;
return result.output.includes(this.relativize(path)!);
}
示例2: getUpstreamBranchFor
async getUpstreamBranchFor(branch: string): Promise<[string, string] | null> {
const result = await git(["rev-parse", "--abbrev-ref", `${branch}@{upstream}`], {
cwd: this.repo.getWorkingDirectory()
});
if (result.failed && result.output.includes("fatal: no upstream configured")) return null;
else return result.output.split("/") as [string, string];
}
示例3: push
push(options: PushOptions = {}): Promise<GitCliResponse> {
const args = ["push"];
if (options.setUpstream) args.push("--set-upstream");
if (options.remote) args.push(options.remote);
if (options.branch) args.push(options.branch);
return git(args, { cwd: this.repo.getWorkingDirectory() });
}
示例4: stage
stage(paths: string[], options: AddOptions = { update: false }): Promise<GitCliResponse> {
const args = ["add"];
if (options.update) args.push("--update");
else args.push("--all");
args.push(...paths);
return git(args, { cwd: this.repo.getWorkingDirectory() });
}
示例5: pull
pull(options: PullOptions = {}): Promise<GitCliResponse> {
const args = ["pull"];
if (options.autostash) args.push("--autostash");
if (options.rebase) args.push("--rebase");
if (options.remote) args.push(options.remote);
if (options.branch) args.push(options.branch);
return git(args, { cwd: this.repo.getWorkingDirectory() });
}
示例6: getBranchesForRemote
async getBranchesForRemote(remote: string): Promise<string[]> {
const { failed, output } = await git(["branch", "-r", "--no-color"], {
cwd: this.repo.getWorkingDirectory()
});
if (failed) return [];
const branches: string[] = [];
output.split("\n").forEach(ref => {
ref = ref.trim();
if (ref.startsWith(`${remote}/`) && !ref.includes("/HEAD")) {
branches.push(ref.substring(ref.indexOf("/") + 1));
}
});
return branches;
}
示例7: getStashes
async getStashes(): Promise<Stash[]> {
const { failed, output } = await git(["stash", "list"], {
cwd: this.repo.getWorkingDirectory()
});
if (failed) return [];
return output
.split("\n")
.filter(Boolean)
.map(stashInfo => {
const [indexInfo, ...rest] = stashInfo.split(":");
const indexMatch = indexInfo.match(/\d+/);
if (!indexMatch) return null;
return { index: indexMatch[0], label: rest.join().trim(), content: stashInfo };
})
.filter(Boolean) as Stash[];
}
示例8: getRemoteNames
async getRemoteNames(): Promise<string[]> {
const { failed, output } = await git(["remote"], { cwd: this.repo.getWorkingDirectory() });
if (failed) return [];
return output.split("\n").filter(Boolean);
}
示例9: getName
getName() {
return path.basename(this.repo.getWorkingDirectory());
}
示例10: getWorkingDirectory
getWorkingDirectory() {
return this.repo.getWorkingDirectory();
}