dugite-extra
Advanced tools
Comparing version 0.0.1-alpha.9 to 0.0.1-alpha.10
@@ -24,5 +24,7 @@ import { ICheckoutProgress } from '../progress'; | ||
* @param repositoryPath the local Git clone or its FS path. | ||
* @param path the absolute file path that has to be checked out. | ||
* @param commitSHA the commit SHA to check out. If not given, `HEAD` will be checked out. | ||
* @param paths the absolute file paths of the resources that have to be checked out. | ||
* @param treeish the commit SHA to check out. If not given, `HEAD` will be checked out. | ||
* @param merge when checking out paths from the index, this option lets you recreate the conflicted merge in the specified paths. | ||
* @param force when checking out paths from the index, do not fail upon unmerged entries; instead, unmerged entries are ignored. | ||
*/ | ||
export declare function checkout(repositoryPath: string, path: string, commitSHA?: string): Promise<void>; | ||
export declare function checkout(repositoryPath: string, paths: string[], commitSHA?: string, merge?: boolean, force?: boolean): Promise<void>; |
@@ -58,2 +58,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var Path = require("path"); | ||
var git_1 = require("../core/git"); | ||
@@ -113,3 +114,3 @@ var progress_1 = require("../progress"); | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, git_1.git(__spread(['checkout', 'HEAD', '--'], paths), repositoryPath, 'checkoutPaths')]; | ||
case 0: return [4 /*yield*/, checkout(repositoryPath, paths, 'HEAD')]; | ||
case 1: | ||
@@ -127,9 +128,30 @@ _a.sent(); | ||
* @param repositoryPath the local Git clone or its FS path. | ||
* @param path the absolute file path that has to be checked out. | ||
* @param commitSHA the commit SHA to check out. If not given, `HEAD` will be checked out. | ||
* @param paths the absolute file paths of the resources that have to be checked out. | ||
* @param treeish the commit SHA to check out. If not given, `HEAD` will be checked out. | ||
* @param merge when checking out paths from the index, this option lets you recreate the conflicted merge in the specified paths. | ||
* @param force when checking out paths from the index, do not fail upon unmerged entries; instead, unmerged entries are ignored. | ||
*/ | ||
function checkout(repositoryPath, path, commitSHA) { | ||
function checkout(repositoryPath, paths, commitSHA, merge, force) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var args; | ||
return __generator(this, function (_a) { | ||
return [2 /*return*/]; | ||
switch (_a.label) { | ||
case 0: | ||
args = ['checkout']; | ||
if (commitSHA) { | ||
args.push(commitSHA); | ||
} | ||
if (merge) { | ||
args.push('-m'); | ||
} | ||
if (force) { | ||
args.push('-f'); | ||
} | ||
args.push('--'); | ||
args.push.apply(args, __spread(paths.map(function (p) { return Path.relative(repositoryPath, p); }))); | ||
return [4 /*yield*/, git_1.git(args, repositoryPath, 'checkoutPaths')]; | ||
case 1: | ||
_a.sent(); | ||
return [2 /*return*/]; | ||
} | ||
}); | ||
@@ -136,0 +158,0 @@ }); |
{ | ||
"name": "dugite-extra", | ||
"version": "0.0.1-alpha.9", | ||
"version": "0.0.1-alpha.10", | ||
"description": "High-level Git commands for dugite.", | ||
@@ -5,0 +5,0 @@ "main": "lib/index", |
@@ -0,1 +1,2 @@ | ||
import * as Path from 'path'; | ||
import { git } from '../core/git' | ||
@@ -54,3 +55,3 @@ import { ChildProcess } from 'child_process' | ||
export async function checkoutPaths(repositoryPath: string, paths: string[]): Promise<void> { | ||
await git(['checkout', 'HEAD', '--', ...paths], repositoryPath, 'checkoutPaths'); | ||
await checkout(repositoryPath, paths, 'HEAD'); | ||
} | ||
@@ -62,7 +63,21 @@ | ||
* @param repositoryPath the local Git clone or its FS path. | ||
* @param path the absolute file path that has to be checked out. | ||
* @param commitSHA the commit SHA to check out. If not given, `HEAD` will be checked out. | ||
* @param paths the absolute file paths of the resources that have to be checked out. | ||
* @param treeish the commit SHA to check out. If not given, `HEAD` will be checked out. | ||
* @param merge when checking out paths from the index, this option lets you recreate the conflicted merge in the specified paths. | ||
* @param force when checking out paths from the index, do not fail upon unmerged entries; instead, unmerged entries are ignored. | ||
*/ | ||
export async function checkout(repositoryPath: string, path: string, commitSHA?: string): Promise<void> { | ||
export async function checkout(repositoryPath: string, paths: string[], commitSHA?: string, merge?: boolean, force?: boolean): Promise<void> { | ||
const args = ['checkout']; | ||
if (commitSHA) { | ||
args.push(commitSHA); | ||
} | ||
if (merge) { | ||
args.push('-m'); | ||
} | ||
if (force) { | ||
args.push('-f'); | ||
} | ||
args.push('--'); | ||
args.push(...paths.map(p => Path.relative(repositoryPath, p))); | ||
await git(args, repositoryPath, 'checkoutPaths'); | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
581236
10493