public CommitDetails GetCommitDetails(string hash) { var details = new CommitDetails(); using (var repository = Open()) { var branch = _getBranch(repository, _branchName); var commit = branch.Commits .FirstOrDefault( x => x.Sha.Equals( hash, StringComparison.OrdinalIgnoreCase)); if (commit == null) { return(null); } details.Message = commit.ToCommitMessage(); var parentCommit = commit.Parents.FirstOrDefault(); var changes = repository.Diff.Compare( parentCommit != null ? parentCommit.Tree : null, commit.Tree); if (changes != null) { var result = new List <FileDiff>(); foreach (var change in changes) { var diff = new FileDiff { Path = change.Path, Patch = change.Patch, Additions = change.LinesAdded, Deletions = change.LinesDeleted }; result.Add(diff); } details.FileDiffs = result; } } return(details); }
public static CommitDetails GetCheckinDetails(string checkinId) { Repository repo = new Repository(ConfigurationManager.AppSettings["RepoRoot"]); //Commit commit = repo.Lookup<Commit>(checkinId); //return commit.Message; string patchDirectory = Path.Combine(repo.Info.Path, "patches"); CommitDetails commitDetails = new CommitDetails(); IEnumerable<string> files = Directory.EnumerateFiles(patchDirectory, checkinId + "*", SearchOption.TopDirectoryOnly); if (files != null && files.Any()) { string patchFileName = files.First(); string commitId = Path.GetFileNameWithoutExtension(patchFileName); commitDetails.Commit = repo.Lookup<Commit>(commitId); commitDetails.FileChanges = Serializer.Deserialize<List<FileChanges>>(File.OpenRead(patchFileName)); } return commitDetails; }
public static CommitDetails GetCheckinDetails(string checkinId) { Repository repo = new Repository(ConfigurationManager.AppSettings["RepoRoot"]); //Commit commit = repo.Lookup<Commit>(checkinId); //return commit.Message; string patchDirectory = Path.Combine(repo.Info.Path, "patches"); CommitDetails commitDetails = new CommitDetails(); IEnumerable <string> files = Directory.EnumerateFiles(patchDirectory, checkinId + "*", SearchOption.TopDirectoryOnly); if (files != null && files.Any()) { string patchFileName = files.First(); string commitId = Path.GetFileNameWithoutExtension(patchFileName); commitDetails.Commit = repo.Lookup <Commit>(commitId); commitDetails.FileChanges = Serializer.Deserialize <List <FileChanges> >(File.OpenRead(patchFileName)); } return(commitDetails); }
public List <CommitDetails> GetCommitDetails() { List <CommitDetails> listOfCommits = new List <CommitDetails>(); var repo = new Repository(@"C:\Work\SMWorkspace\Bonobo\newrepo"); foreach (Branch branch in repo.Branches) { foreach (Commit commit in branch.Commits) { var details = new CommitDetails { Author = commit.Author.Name, Message = commit.Message, Time = commit.Author.When.DateTime, Branch = branch.FriendlyName }; listOfCommits.Add(details); } } return(listOfCommits); }
public async Task CommitChangesAsync(string mergeCommitMessage = null) { Repository repository = repositoryMgr.Repository; var uncommitted = repository.UnComitted; if (uncommitted != null) { if (uncommitted.HasConflicts) { message.ShowInfo("There are merge conflicts that needs be resolved before committing."); repositoryCommands.ShowCommitDetails(); return; } } else { message.ShowInfo("No changes, nothing to commit."); return; } BranchName branchName = repository.CurrentBranch.Name; using (statusService.PauseStatusNotifications()) { if (repository.CurrentBranch.IsDetached) { message.ShowInfo( "Current branch is in detached head status.\n" + "You must first create or switch to branch before commit."); return; } CommitDetails commitDetails = await uncommitted.FilesTask; IEnumerable <CommitFile> commitFiles = commitDetails.Files; string commitMessage = mergeCommitMessage ?? repository.Status.MergeMessage; CommitDialog dialog = commitDialogProvider( branchName, commitFiles, commitMessage, repository.Status.IsMerging); if (dialog.ShowDialog() == true) { using (progress.ShowDialog($"Committing current branch {branchName} ...")) { R <GitCommit> gitCommit = await CommitAsync( dialog.CommitMessage, branchName, dialog.CommitFiles); if (!gitCommit.IsOk) { message.ShowWarning("Failed to commit"); } } Log.Debug("After commit dialog, refresh done"); } else if (repository.Status.IsMerging && !commitFiles.Any()) { await gitStatusService.UndoAllUncommittedAsync(CancellationToken.None); } } }
public ReleasePackageVersionMetadata() { WorkItems = new WorkItemLink[0]; Commits = new CommitDetails[0]; }
public void WhenIPressTheSelectStoriesButton() { originalCommitDetails = fixture.Create<CommitDetails>(); selectStoriesTask = provider.GetNewCommitMessage(originalCommitDetails); selectStoriesTask.IsFaulted.ShouldBe(false); }
public void Should_delegate_to_IBugTrackProvider() { var bugTrackProvider = new Mock<IBugTrackProvider>(); plugin.BugTrackProvider = bugTrackProvider.Object; var result = fixture.Create<CommitDetails>(); bugTrackProvider .Setup(x => x.GetNewCommitMessage(It.IsAny<CommitDetails>())) .Returns(Task.FromResult(result)); var hParentWnd = default(IntPtr); var parameters = fixture.Create<string>(); var commonUrl = fixture.Create<string>(); var commonRoot = fixture.Create<string>(); var pathList = fixture.Create<string[]>(); var originalMessage = fixture.Create<string>(); var bugId = fixture.Create<string>(); string bugIdOut; string[] revPropNames; string[] revPropValues; var newMessage = plugin.GetCommitMessage2( hParentWnd, parameters, commonUrl, commonRoot, pathList, originalMessage, bugId, out bugIdOut, out revPropNames, out revPropValues); var exptectedCommitDetails = new CommitDetails { Message = originalMessage }; bugTrackProvider.Verify(x => x.GetNewCommitMessage(It.Is<CommitDetails>(d => d.IsDeepEqual(exptectedCommitDetails)))); newMessage.ShouldBe(result.Message); }