private static void AddGitHooksToFolder(string folderPath, string ignoreFilter = null) { if (!Directory.Exists(folderPath)) { return; } string[] gitHookPaths = GitHookFinder.FindGitHooksInProject(); for (int i = 0; i < gitHookPaths.Length; i++) { string sourcePath = gitHookPaths[i]; string fileName = Path.GetFileName(sourcePath); if (string.IsNullOrEmpty(ignoreFilter) != true) { if (fileName.Equals(ignoreFilter)) { return; } } string targetPath = folderPath + fileName; FileUtilities.CopyFile(sourcePath, targetPath, true); } }
/// <summary> /// Check if githooks already exist in the directory /// </summary> /// <param name="folderPath"></param> /// <returns>returns true if all of the hooks exist</returns> private static bool FolderContainsAllGitHooks(string folderPath) { string[] gitHookPaths = GitHookFinder.FindGitHooksInProject(); for (int i = 0; i < gitHookPaths.Length; i++) { string sourcePath = gitHookPaths[i]; string fileName = Path.GetFileName(sourcePath); string targetPath = folderPath + fileName; if (!FileUtilities.FileExists(targetPath)) { return(false); } } return(true); }