From 20f2eb68324237ef4bbd1678613ce78c193366f7 Mon Sep 17 00:00:00 2001 From: Philippe Miossec Date: Fri, 24 May 2013 23:36:37 +0200 Subject: [PATCH] clone: verify if tfs path exists --- GitTfs.VsCommon/TfsHelper.Common.cs | 4 ++++ GitTfs.VsFake/TfsHelper.VsFake.cs | 5 +++++ GitTfs/Commands/Clone.cs | 5 +++++ GitTfs/Core/TfsInterop/ITfsHelper.cs | 1 + 4 files changed, 15 insertions(+) diff --git a/GitTfs.VsCommon/TfsHelper.Common.cs b/GitTfs.VsCommon/TfsHelper.Common.cs index fd71e267..0d7fc6ce 100644 --- a/GitTfs.VsCommon/TfsHelper.Common.cs +++ b/GitTfs.VsCommon/TfsHelper.Common.cs @@ -653,5 +653,9 @@ namespace Sep.Git.Tfs.VsCommon } + public bool IsExistingInTfs(string path) + { + return VersionControl.ServerItemExists(path, ItemType.Any); + } } } diff --git a/GitTfs.VsFake/TfsHelper.VsFake.cs b/GitTfs.VsFake/TfsHelper.VsFake.cs index 3aef6f5f..6e5e14ae 100644 --- a/GitTfs.VsFake/TfsHelper.VsFake.cs +++ b/GitTfs.VsFake/TfsHelper.VsFake.cs @@ -375,6 +375,11 @@ namespace Sep.Git.Tfs.VsFake { throw new NotImplementedException(); } + + public bool IsExistingInTfs(string path) + { + throw new NotImplementedException(); + } #endregion } } diff --git a/GitTfs/Commands/Clone.cs b/GitTfs/Commands/Clone.cs index 1ca4f460..c0a68bf6 100644 --- a/GitTfs/Commands/Clone.cs +++ b/GitTfs/Commands/Clone.cs @@ -102,6 +102,11 @@ namespace Sep.Git.Tfs.Commands if (initBranch != null) { var remote = globals.Repository.ReadTfsRemote(GitTfsConstants.DefaultRepositoryId); + + if (!remote.Tfs.IsExistingInTfs(tfsRepositoryPath)) + throw new GitTfsException("error: the path " + tfsRepositoryPath + " you want to clone doesn't exist!") + .WithRecommendation("To discover which branch to clone, you could use the command :\ngit tfs list-remote-branches " + remote.TfsUrl); + if (!remote.Tfs.CanGetBranchInformation) return; var tfsTrunkRepository = remote.Tfs.GetRootTfsBranchForRemotePath(tfsRepositoryPath, false); diff --git a/GitTfs/Core/TfsInterop/ITfsHelper.cs b/GitTfs/Core/TfsInterop/ITfsHelper.cs index 8ed4434a..9c06e886 100644 --- a/GitTfs/Core/TfsInterop/ITfsHelper.cs +++ b/GitTfs/Core/TfsInterop/ITfsHelper.cs @@ -33,5 +33,6 @@ namespace Sep.Git.Tfs.Core.TfsInterop IEnumerable GetBranches(); void EnsureAuthenticated(); void CreateBranch(string sourcePath, string targetPath, int changesetId, string comment = null); + bool IsExistingInTfs(string path); } }