From 73abf84f51e71ead1d327fc0fb53dff15a4367c7 Mon Sep 17 00:00:00 2001 From: Philippe Miossec Date: Thu, 10 Jul 2014 14:42:35 +0200 Subject: [PATCH] Add a parameter to only return the sha of a commit given a changeset id --- GitTfs/Commands/Checkout.cs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/GitTfs/Commands/Checkout.cs b/GitTfs/Commands/Checkout.cs index 5a6e88ed..ae9471a0 100644 --- a/GitTfs/Commands/Checkout.cs +++ b/GitTfs/Commands/Checkout.cs @@ -29,11 +29,14 @@ namespace Sep.Git.Tfs.Commands return new OptionSet { { "b|branch=", "Name of the branch to create", v => BranchName = v }, + { "n|dry-run", "Don't checkout the commit, just return commit sha", v => ReturnShaOnly = v != null }, }; } } + protected string BranchName { get; set; } + protected bool ReturnShaOnly { get; set; } public int Run(string id) { @@ -43,6 +46,11 @@ namespace Sep.Git.Tfs.Commands var sha = _globals.Repository.FindCommitHashByChangesetId(changesetId); if (string.IsNullOrEmpty(sha)) throw new GitTfsException("error: commit not found for this changeset id..."); + if (ReturnShaOnly) + { + _stdout.Write(sha); + return GitTfsExitCodes.OK; + } string commitishToCheckout = sha; if (!string.IsNullOrEmpty(BranchName)) {