public static string[] generateErrorReport(Client client) { if (!client.IsLocal) { return(new string[0]); } if (!cache.ContainsKey(client.Name)) { OldLogger.Start("generateErrorReport - " + client.Path); List <string> result = new List <string>(); #if false SearchOption searchOption = SearchOption.AllDirectories; #if DEBUG searchOption = SearchOption.TopDirectoryOnly; #endif List <string> errorFiles = new List <string>(Directory.EnumerateFiles(client.Path, "build*.err", searchOption)); for (int ii = 0; ii < errorFiles.Count; ii++) { Debug.Assert(File.Exists(errorFiles[ii])); result.Add("Build error file found at:" + errorFiles[ii]); } errorFiles = new List <string>(Directory.EnumerateFiles(client.Path, "build*.wrn", searchOption)); for (int ii = 0; ii < errorFiles.Count; ii++) { Debug.Assert(File.Exists(errorFiles[ii])); result.Add("Build warning file found at:" + errorFiles[ii]); } #endif OldLogger.Stop("generateErrorReport - " + client.Path); cache.Add(client.Name, result.ToArray()); } Debug.Assert(cache.ContainsKey(client.Name)); return(cache[client.Name]); }
static void Main(string[] args) { #if DEBUG OldLogger.AnnounceStartStopActions = true; OldLogger.Level = OldLogger.LevelValue.Verbose; #endif string currentBranch = GitOperations.GetCurrentBranchName(); List <string> branches = new List <string>(GitOperations.GetLocalBranches()); branches.Remove(currentBranch); OldLogger.LogLine(@"Currently on " + currentBranch); OldLogger.LogLine(@"Select from the following:"); for (int ii = 0; ii < Math.Min(9, branches.Count); ii++) { OldLogger.LogLine("\t" + (ii + 1) + " : " + branches[ii]); } OldLogger.LogLine("\tn : Make a new branch"); OldLogger.LogLine("\tf : Follow an existing remote branch"); string input = Console.ReadKey().KeyChar.ToString().Trim().ToLower(); OldLogger.LogLine(string.Empty); if (string.IsNullOrEmpty(input) || (input.ToLower() == "q")) { return; } if (input.ToLower() == "n") { MakeNewBranch(); return; } if (input.ToLower() == "f") { FollowExistingRemoteBranch(); return; } if ((input == "-") || (input == "--")) { SwitchBranch("-"); OldLogger.LogLine("Branch is now : " + GitOperations.GetCurrentBranchName()); return; } int index = -1; if (!int.TryParse(input, out index)) { OldLogger.LogLine(@"Not a valid number: " + input, OldLogger.LevelValue.Error); return; } if ((index <= 0) || (index > branches.Count)) { OldLogger.LogLine(@"Invalid index: " + index, OldLogger.LevelValue.Error); return; } SwitchBranch(branches[index - 1]); }
private static void SwitchBranch(string newBranch) { if (!GitOperations.SwitchBranch(newBranch, out ProcessHelper proc)) { OldLogger.LogLine("Unable to switch branches", OldLogger.LevelValue.Error); OldLogger.LogLine(proc.AllOutput, OldLogger.LevelValue.Warning); } }
private static void CreateBranch(string branchName, string basedOn) { if (!GitOperations.CreateBranch(branchName, basedOn, out ProcessHelper proc)) { OldLogger.LogLine("Unable to create your branch", OldLogger.LevelValue.Error); OldLogger.LogLine(proc.AllOutput, OldLogger.LevelValue.Warning); } }
private static void ApplyChanges(string masterBranch, string fromVersion, string toVersion) { string gitRootDir = GitOperations.GetRoot(); Debug.Assert(Directory.Exists(gitRootDir)); string currentDir = Directory.GetCurrentDirectory(); Debug.Assert(IOHelper.IsSubdirectory(gitRootDir, currentDir)); string[] directoriesWithDifferences = GitOperations.GetDifferentFiles(masterBranch) .Where(path => path.ToLower().Contains("/" + fromVersion.ToLower() + "/")) .Select(path => path.Substring(0, path.ToLower().IndexOf(fromVersion.ToLower()))) .Distinct() .ToArray(); Dictionary <string, string> patchPaths = new Dictionary <string, string>(); OldLogger.Start("Generating Patches", OldLogger.LevelValue.Normal); foreach (string directoryWithDifference in directoriesWithDifferences) { string patchPath = Path.Combine(gitRootDir, fromVersion + "." + directoryWithDifference.Replace('\\', '-').Replace('/', '-').Trim(new char[] { '-' }) + ".patch"); // git format-patch --relative origin/master . --stdout ProcessHelper proc = new ProcessHelper(@"C:\Program Files\Git\cmd\git.exe", $"format-patch --relative {masterBranch} . --stdout"); proc.WorkingDirectory = Path.Combine(gitRootDir, directoryWithDifference, fromVersion); proc.Go(); File.WriteAllText(patchPath, string.Join("\n", proc.RawOutput)); patchPaths.Add(directoryWithDifference, patchPath); } OldLogger.Stop("Generating Patches", OldLogger.LevelValue.Normal); for (int ii = 0; ii < directoriesWithDifferences.Length; ii++) { string directoryWithDifference = directoriesWithDifferences[ii]; string destinationDirectory = Path.Combine(gitRootDir, directoryWithDifference, toVersion).Replace('\\', '/'); string patchPath = patchPaths[directoryWithDifference]; OldLogger.Start("Applying changes to " + destinationDirectory, OldLogger.LevelValue.Normal); // git apply --reject --directory=<destination-dir> --unsafe-paths <patch-path> ProcessHelper proc = new ProcessHelper("git.exe", $"apply --reject --directory={destinationDirectory} --unsafe-paths {patchPath}"); proc.WorkingDirectory = gitRootDir; proc.Go(); foreach (string line in proc.RawOutput) { Console.WriteLine(line); } OldLogger.Stop("Applying changes to " + destinationDirectory, OldLogger.LevelValue.Normal); if (proc.RawOutput.Length > 0 && ii < directoriesWithDifferences.Length - 1) { Console.WriteLine("Press any key to continue"); Console.ReadKey(); } } }
static void Main(string[] args) { OldLogger.AnnounceStartStopActions = false; #if DEBUG OldLogger.AnnounceStartStopActions = true; #endif GitStatus status = GitStatus.Get(); string root = Environment.GetEnvironmentVariable("REPO_ROOT"); OldLogger.LogLine(String.Join(" ", new string[] { root, status.Branch, status.RemoteChanges, status.AllLocalChanges })); }
static bool RevertFile(string filePath) { ProcessHelper proc = new ProcessHelper("git.exe", @"checkout -- " + filePath); proc.Go(); if (proc.ExitCode != 0 || proc.StandardError.Length != 0) { OldLogger.LogLine("Unable to revert " + filePath, OldLogger.LevelValue.Warning); return(false); } return(true); }
private static void MakeNewBranch() { string suggestedPrefix = "u/" + Environment.GetEnvironmentVariable("USERNAME") + "/"; OldLogger.Log("\r\nPrefix? [" + suggestedPrefix + "] : "); string prefix = Console.ReadLine().Trim().ToLower().Replace('_', '-').Replace(' ', '-'); if (string.IsNullOrEmpty(prefix)) { prefix = suggestedPrefix; } OldLogger.Log("Short name : "); string shortName = Console.ReadLine().Trim().ToLower().Replace('_', '-').Replace(' ', '-'); if (string.IsNullOrEmpty(shortName)) { OldLogger.LogLine("Short name must be provided!", OldLogger.LevelValue.Error); return; } string branchName = string.Join("/", string.Join("/", new string[] { prefix, shortName }).Split(new char[] { '/' }, StringSplitOptions.RemoveEmptyEntries)); string suggestedBasedOn = GitOperations.GetBranchBase(GitOperations.GetCurrentBranchName()); if (string.IsNullOrEmpty(suggestedBasedOn)) { suggestedBasedOn = GetDefaultBranch(); } OldLogger.Log("Based on what branch? [" + suggestedBasedOn + "] : "); string basedOn = Console.ReadLine().Trim(); if (string.IsNullOrEmpty(basedOn)) { basedOn = suggestedBasedOn; } string remoteBranchName = "origin/" + branchName; OldLogger.LogLine("Confirming new branch called " + branchName + " based on " + basedOn); OldLogger.LogLine("This will also be tracking " + remoteBranchName); OldLogger.Log("That look ok? [y] "); string prompt = Console.ReadKey().KeyChar.ToString().Trim().ToLower(); OldLogger.LogLine(string.Empty); if (string.IsNullOrEmpty(prompt)) { prompt = "y"; } if (prompt == "y") { CreateBranch(branchName, basedOn); } }
private static void MergeBranch(string localBranch, string mergeSource) { if (!GitOperations.IsBranchBehind(localBranch, mergeSource)) { OldLogger.LogLine(localBranch + " is up to date with " + mergeSource); return; } if (!GitOperations.SwitchBranch(localBranch, out ProcessHelper failureProc)) { OldLogger.LogLine("Unable to switch branches", OldLogger.LevelValue.Warning); OldLogger.LogLine(failureProc.AllOutput, OldLogger.LevelValue.Normal); return; } GitOperations.MergeFromBranch(mergeSource); }
private static bool UpdateBranch(string localBranch, string remoteBranch = null) { remoteBranch = remoteBranch ?? ("origin/" + localBranch); if (!GitOperations.IsBranchBehind(localBranch, remoteBranch)) { OldLogger.LogLine($"{localBranch} is up to date with {remoteBranch}"); return(false); } if (!GitOperations.SwitchBranch(localBranch, out ProcessHelper failureProc)) { OldLogger.LogLine("Unable to switch branches", OldLogger.LevelValue.Warning); OldLogger.LogLine(failureProc.AllOutput, OldLogger.LevelValue.Normal); return(false); } GitOperations.PullCurrentBranch(); return(true); }
static int Main(string[] args) { ConsoleLogger.Instance.IncludeEventType = false; Test("032fa944-399a-4c04-9090-7ce1fd722a0d", "d6d64cae9b4074b5c02f574d12de535f", true); Test(" 032fa944-399a-4c04-9090-7ce1fd722a0d ", " d6d64cae9b4074b5c02f574d12de535f ", true); Test("/032fa944-399a-4c04-9090-7ce1fd722a0d/capture-schedules/d6d64cae9b4074b5c02f574d12de535f", "", true); Test(" /032fa944-399a-4c04-9090-7ce1fd722a0d/capture-schedules/d6d64cae9b4074b5c02f574d12de535f/ ", "", true); Test("032fa944-399a-4c04-9090-7ce1fd722a0d,d6d64cae9b4074b5c02f574d12de535f", "", true); Test(" 032fa944-399a-4c04-9090-7ce1fd722a0d , d6d64cae9b4074b5c02f574d12de535f ", "", true); Test("032fa944-399a-4c04-9090-7ce1fd722a0d d6d64cae9b4074b5c02f574d12de535f", "", true); Test(" 032fa944-399a-4c04-9090-7ce1fd722a0d d6d64cae9b4074b5c02f574d12de535f ", "", true); Test("032fa944-399a-4c04-9090-7ce1fd722a0d/d6d64cae9b4074b5c02f574d12de535f", "", true); Test(" 032fa944-399a-4c04-9090-7ce1fd722a0d / d6d64cae9b4074b5c02f574d12de535f ", "", true); Test(" 032fa944-399a-4c04-9090-7ce1fd722a0d / d6d64cae9b4074b5c02f574d12de535f ", "", true); Test("032fa944-399a-4c04-9090-7ce1fd722a0d", "d6d64cae9b40702f574d12de535f", false); Test(" 032fa944-399a-4c04-9090-7ce1fd722a0d ", " d6d64cae9b40702f574d12de535f ", false); Test("/032fa944-399a-4c04-9090-7ce1fd722a0d/capture-schedules/d6d64cae9b40702f574d12de535f", "", false); Test(" /032fa944-399a-4c04-9090-7ce1fd722a0d/capture-schedules/d6d64cae9b40702f574d12de535f/ ", "", false); Test("032fa944-399a-4c04-9090-7ce1fd722a0d,d6d64cae9b40702f574d12de535f", "", false); Test(" 032fa944-399a-4c04-9090-7ce1fd722a0d , d6d64cae9b40702f574d12de535f ", "", false); Test("032fa944-399a-4c04-9090-7ce1fd722a0d d6d64cae9b40702f574d12de535f", "", false); Test(" 032fa944-399a-4c04-9090-7ce1fd722a0d d6d64cae9b40702f574d12de535f ", "", false); Test("032fa944-399a-4c04-9090-7ce1fd722a0d/d6d64cae9b40702f574d12de535f", "", false); Test(" 032fa944-399a-4c04-9090-7ce1fd722a0d / d6d64cae9b40702f574d12de535f ", "", false); Test("/032fa944-399a-4c04-9090-7ce1fd722a0d/capture-schedules/d6d64cae9b4074b5c02f574d12de535f", "d6d64cae9b40702f574d12de535f", false); Test(" /032fa944-399a-4c04-9090-7ce1fd722a0d/capture-schedules/d6d64cae9b4074b5c02f574d12de535f/ ", "d6d64cae9b40702f574d12de535f", false); Test("032fa944-399a-4c04-9090-7ce1fd722a0d,d6d64cae9b4074b5c02f574d12de535f", "d6d64cae9b40702f574d12de535f", false); Test(" 032fa944-399a-4c04-9090-7ce1fd722a0d , d6d64cae9b4074b5c02f574d12de535f ", "d6d64cae9b40702f574d12de535f", false); Test("032fa944-399a-4c04-9090-7ce1fd722a0d d6d64cae9b4074b5c02f574d12de535f", "d6d64cae9b40702f574d12de535f", false); Test(" 032fa944-399a-4c04-9090-7ce1fd722a0d d6d64cae9b4074b5c02f574d12de535f ", "d6d64cae9b40702f574d12de535f", false); Test("032fa944-399a-4c04-9090-7ce1fd722a0d/d6d64cae9b4074b5c02f574d12de535f", "d6d64cae9b40702f574d12de535f", false); Test(" 032fa944-399a-4c04-9090-7ce1fd722a0d / d6d64cae9b4074b5c02f574d12de535f ", "d6d64cae9b40702f574d12de535f", false); Test(" 032fa944-399a-4c04-9090-7ce1fd722a0d d6d64cae9b4074b5c02f574d12de535f ", "", true); return(0); Dictionary <string, List <Counts> > dict = new Dictionary <string, List <Counts> >(); ProcessHelper proc = new ProcessHelper("git.exe", "log -n 1200 --pretty=\"%H %ae %ad\""); int maxAuthorLength = 0; foreach (string line in proc.Go()) { string[] splits = line.Split(new char[] { ' ' }); string commitId = splits[0]; string author = StringHelper.TrimEnd(splits[1], "@microsoft.com"); maxAuthorLength = Math.Max(maxAuthorLength, author.Length); GitOperations.GetCommitStats(commitId, out int fileCount, out int insertCount, out int deleteCount); if (!dict.ContainsKey(author)) { dict[author] = new List <Counts>(); } dict[author].Add(new Counts(commitId, fileCount, insertCount, deleteCount)); OldLogger.Log("."); } OldLogger.LogLine(" done"); foreach (string author in dict.Keys) { List <Counts> list = dict[author]; int totalFileCount = 0; int totalInsertCount = 0; int totalDeleteCount = 0; foreach (Counts count in list) { totalFileCount += count.files; totalInsertCount += count.inserts; totalDeleteCount += count.deletes; } string fileCountString = PluralStringCheck(totalFileCount, "file changed", "files changed"); string insertCountString = PluralStringCheck(totalFileCount, "insertion(+)", "insertions(+)"); string deleteCountString = PluralStringCheck(totalFileCount, "deletion(+)", "deletions(+)"); string netCountString = PluralStringCheck((totalInsertCount - totalDeleteCount), "net line changed", "net lines changed"); OldLogger.LogLine(("Author: " + author).PadRight(maxAuthorLength + 10) + fileCountString.PadRight(20) + insertCountString.PadRight(20) + deleteCountString.PadRight(20) + netCountString); } foreach (string author in dict.Keys) { List <Counts> list = dict[author]; int totalFileCount = 0; int totalInsertCount = 0; int totalDeleteCount = 0; foreach (Counts count in list) { totalFileCount += count.files; totalInsertCount += count.inserts; totalDeleteCount += count.deletes; } OldLogger.LogLine(author.PadRight(maxAuthorLength + 10) + totalFileCount.ToString().PadRight(20) + totalInsertCount.ToString().PadRight(20) + totalDeleteCount.ToString().PadRight(20)); } foreach (string author in dict.Keys) { OldLogger.LogLine("------------------------------------"); OldLogger.LogLine("Author: " + author); List <Counts> list = dict[author]; foreach (Counts count in list) { OldLogger.LogLine(count.commit.PadRight(45) + count.files.ToString().PadRight(20) + count.inserts.ToString().PadRight(20) + count.deletes.ToString().PadRight(20)); } } return(0); }
static void Main(string[] args) { //List<GitFileInfo> toBeRemoved = new List<GitFileInfo>(); //GitFileInfo[] gitInfos = GitStatus.Get().GetFiles(false /*staged*/); //foreach (GitFileInfo gitInfo in gitInfos) //{ // if (gitInfo.FileState == FileState.Modified && File.Exists(gitInfo.FilePath)) // { // FileInfo fileInfo = new FileInfo(gitInfo.FilePath); // if (fileInfo.Length < 4) // { // Logger.LogLine("Deleted: " + gitInfo.FilePath); // toBeRemoved.Add(gitInfo); // } // } //} List <string> toBeRemoved = new List <string>(); List <string> possiblyRemovedFiles = new List <string>(GetAllFiles(new string[] { "h", "cpp", "xaml" })); foreach (string possiblyRemovedFilePath in possiblyRemovedFiles) { if (File.Exists(possiblyRemovedFilePath)) { FileInfo fileInfo = new FileInfo(possiblyRemovedFilePath); if (fileInfo.Length < 4) { OldLogger.LogLine("Deleted: " + possiblyRemovedFilePath); File.Delete(possiblyRemovedFilePath); toBeRemoved.Add(Path.GetFileName(possiblyRemovedFilePath)); } } } //List<string> allFiles = new List<string>(GetAllFiles(new string[] { "h", "cpp", "vcxproj", "filters" })); List <string> allFiles = new List <string>(GetAllFiles(new string[] { "vcxproj", "vcxitems", "vcxproj.filters", "vcxitems.filters" })); foreach (string file in allFiles) { List <string> removedLines = new List <string>(); List <string> lines = new List <string>(File.ReadAllLines(file)); for (int ii = 0; ii < lines.Count; ii++) { //foreach (GitFileInfo gitInfo in toBeRemoved) foreach (string removedFilePath in toBeRemoved) { if (lines[ii].ToLower().Contains(removedFilePath.ToLower())) { removedLines.Add(lines[ii]); lines.RemoveAt(ii); ii--; break; } } } if (removedLines.Count > 0) { OldLogger.LogLine(@"Lines to be removed from " + file + " :"); foreach (string removedLine in removedLines) { OldLogger.LogLine("\t" + removedLine.Trim()); } File.WriteAllLines(file, lines, Utilities.IOHelper.GetEncoding(file)); } } }
private static void FollowExistingRemoteBranch() { string searchTerm = Environment.GetEnvironmentVariable("USERNAME").ToLower(); #if DEBUG searchTerm = "personal"; #endif string[] localBranches = StringHelper.ToLower(GitOperations.GetLocalBranches()); List <string> remoteBranches = new List <string>(GitOperations.GetRemoteBranches("--sort committerdate")); for (int ii = 0; ii < remoteBranches.Count; ii++) { string lowerRemoteBranch = StringHelper.TrimStart(remoteBranches[ii].ToLower(), "origin/"); if (localBranches.Contains(lowerRemoteBranch)) { remoteBranches.RemoveAt(ii--); } } List <string> matchingBranches = new List <string>(); foreach (string remoteBranch in remoteBranches) { if (remoteBranch.ToLower().Contains(searchTerm)) { matchingBranches.Add(remoteBranch); } } if (matchingBranches.Count > 0) { OldLogger.LogLine(@"Select from the following:"); for (int ii = 0; ii < matchingBranches.Count; ii++) { OldLogger.LogLine("\t" + (ii + 1) + " : " + matchingBranches[ii]); } OldLogger.Log("Or"); } OldLogger.LogLine("Enter another branch name"); string prompt = Console.ReadLine().Trim(); if (string.IsNullOrEmpty(prompt) || (prompt.ToLower() == "q")) { return; } string basedOn = string.Empty; if (remoteBranches.Contains(prompt)) { basedOn = prompt; } else if (remoteBranches.Contains("origin/" + prompt)) { basedOn = "origin/" + prompt; } else { int index = -1; if (int.TryParse(prompt, out index) && (index > 0) && (index <= matchingBranches.Count)) { basedOn = matchingBranches[index - 1]; } } if (string.IsNullOrEmpty(basedOn)) { OldLogger.LogLine("Unable to find the given branch: " + prompt, OldLogger.LevelValue.Error); return; } CreateBranch(StringHelper.TrimStart(basedOn, "origin/"), basedOn); }
static int Main(string[] args) { bool forceDelete = false; #if DEBUG OldLogger.Level = OldLogger.LevelValue.Verbose; OldLogger.AnnounceStartStopActions = true; #endif for (int ii = 0; ii < args.Length; ii++) { string arg = args[ii].ToLower(); switch (arg) { case "/v": case "/verbose": OldLogger.AnnounceStartStopActions = true; OldLogger.Level = OldLogger.LevelValue.Verbose; break; case "/log": OldLogger.AddLogFile(args[++ii]); break; case "/html": OldLogger.AddHTMLLogFile(args[++ii]); break; case "/vlog": OldLogger.AnnounceStartStopActions = true; OldLogger.AddLogFile(args[++ii], OldLogger.LevelValue.Verbose); break; case "/fd": forceDelete = true; break; default: Console.WriteLine("Unknown argument: " + arg); PrintUsage(); OldLogger.FlushLogs(); return((int)OldLogger.WarningCount); } } string verboseLogFile = OldLogger.VerboseLogPath; if (!string.IsNullOrEmpty(verboseLogFile)) { OldLogger.LogLine("Verbose log path: " + verboseLogFile); } OldLogger.Log("Fetching... "); GitOperations.FetchAll(); OldLogger.LogLine("done"); OldLogger.LogLine(@"Examining local branches..."); List <BranchInfo> localBranches = GitOperations.GetLocalBranches().Select(x => new BranchInfo(x)).ToList(); string defaultBranchName = GitOperations.GetDefaultBranch(); BranchInfo localDefaultBranch = localBranches.FirstOrDefault(x => x.Name == defaultBranchName); if (localDefaultBranch == null) { defaultBranchName = "origin/" + defaultBranchName; } else { localDefaultBranch.IsDefault = true; } List <string> remoteBranches = new List <string>(GitOperations.GetRemoteBranches()); foreach (BranchInfo branch in localBranches) { branch.HasRemoteBranch = remoteBranches.Contains(branch.Name) || remoteBranches.Contains("origin/" + branch.Name) || branch.Name.Contains("HEAD"); if (!branch.HasRemoteBranch) { OldLogger.LogLine($"Remote branch is gone for {branch.Name}", OldLogger.LevelValue.Warning); } } List <BranchInfo> unparentedBranches = localBranches.Where(x => !x.IsParented && !x.IsDefault).ToList(); if (unparentedBranches.Count > 0) { foreach (BranchInfo branch in unparentedBranches) { OldLogger.LogLine($"{branch.Name} has no parent branch"); } string exampleBranchName = "<branch name>"; if (unparentedBranches.Count == 1) { exampleBranchName = unparentedBranches.First().Name; } OldLogger.LogLine($"To set {defaultBranchName} as the parent branch, run the following command:"); OldLogger.LogLine($"\tgit config branch.{exampleBranchName}.basedon {defaultBranchName}"); } GitStatus originalStatus = GitOperations.GetStatus(); string originalBranchName = originalStatus.Branch; OldLogger.LogLine("\r\nStarted in " + originalBranchName); if (originalStatus.AnyChanges) { if (!GitOperations.Stash()) { OldLogger.LogLine("Unable to stash the current work. Cannot continue.", OldLogger.LevelValue.Error); OldLogger.FlushLogs(); return((int)OldLogger.WarningCount); } } // // Delete local branches that don't have a remote branch // ProcessHelper failureProc = null; foreach (BranchInfo branch in localBranches.Where(x => !x.HasRemoteBranch && !x.IsDefault)) { if (GitOperations.GetCurrentBranchName() == branch.Name) { if (!GitOperations.SwitchBranch(defaultBranchName, out failureProc)) { OldLogger.LogLine("Unable to switch branches", OldLogger.LevelValue.Warning); OldLogger.LogLine(failureProc.AllOutput, OldLogger.LevelValue.Normal); continue; } } if (GitOperations.DeleteBranch(branch.Name, force: forceDelete)) { if (branch.Name == originalBranchName) { originalBranchName = defaultBranchName; } branch.IsDeleted = true; } } localBranches = localBranches.Where(x => !x.IsDeleted).ToList(); foreach (BranchInfo branch in SortParentBranchesFirst(localBranches)) { OldLogger.LogLine(string.Empty); UpdateBranch(branch.Name); if (branch.IsParented) { MergeBranch(branch.Name, branch.ParentBranchName); } } OldLogger.LogLine(string.Empty); if (!GitOperations.SwitchBranch(originalBranchName, out failureProc)) { OldLogger.LogLine("Unable to switch branches", OldLogger.LevelValue.Error); OldLogger.LogLine(failureProc.AllOutput, OldLogger.LevelValue.Warning); OldLogger.FlushLogs(); return((int)OldLogger.WarningCount); } if (originalStatus.AnyChanges) { GitOperations.StashPop(); } OldLogger.FlushLogs(); return((int)OldLogger.WarningCount); }
public OldLoggerToNewLoggerAdapter(OldLogger oldLogger) { this.oldLogger = oldLogger; }
static void Main(string[] args) { #if DEBUG //Logger.AnnounceStartStopActions = true; OldLogger.Level = OldLogger.LevelValue.Verbose; #endif bool localOnly = false; DateTime aMonthAgo = DateTime.Now.AddMonths(-1); string aMonthAgoString = aMonthAgo.ToShortDateString(); string[] branches; if (localOnly) { branches = GitOperations.GetLocalBranches(); } else { branches = GitOperations.GetRemoteBranches(); } List <string> lines = new List <string>(); foreach (string branch in branches) { if (!branch.Contains(" -> ")) { OldLogger.Log(".", OldLogger.LevelValue.Verbose); ProcessHelper proc = new ProcessHelper("git.exe", "log -n 1 --since=" + aMonthAgoString + " " + branch); if (proc.Go().Length == 0) { string[] changeDescription = (new ProcessHelper("git.exe", "log --date=short --pretty=format:\"%an,%ae," + StringHelper.TrimStart(branch, "origin/") + ",%ad\" -n 1 " + branch)).Go(); Debug.Assert(changeDescription.Length == 1); lines.Add(changeDescription[0]); } } } OldLogger.LogLine("", OldLogger.LevelValue.Verbose); lines.Sort(); OldLogger.LogLine(lines.ToArray()); OldLogger.LogLine(string.Empty); lines = new List <string>(); foreach (string branch in branches) { if (branch.ToLower().StartsWith(@"origin/u/")) { continue; } if (branch.ToLower().StartsWith(@"origin/user/")) { continue; } if (branch.ToLower().StartsWith(@"origin/users/")) { continue; } if (branch.ToLower().StartsWith(@"origin/feature/")) { continue; } if (branch.ToLower().StartsWith(@"origin/features/")) { continue; } if (branch.ToLower().StartsWith(@"origin/release/")) { continue; } if (branch.Contains(" -> ")) { continue; } OldLogger.LogLine(branch); string[] changeDescription = (new ProcessHelper("git.exe", "log --date=short --pretty=format:\"%an (%ae) was the last person to touch " + StringHelper.TrimStart(branch, "origin/") + " on %ad\" -n 1 " + branch)).Go(); Debug.Assert(changeDescription.Length == 1); lines.Add(changeDescription[0]); } OldLogger.LogLine("", OldLogger.LevelValue.Verbose); lines.Sort(); OldLogger.LogLine(lines.ToArray()); }