public Rcheckin(TextWriter stdout, CheckinOptions checkinOptions, TfsWriter writer) { _stdout = stdout; _checkinOptions = checkinOptions; _checkinOptionsFactory = new CommitSpecificCheckinOptionsFactory(_stdout); _writer = writer; }
public static CheckinOptions Clone(this CheckinOptions source, Globals globals) { CheckinOptions clone = new CheckinOptions(); clone.CheckinComment = source.CheckinComment; clone.NoGenerateCheckinComment = source.NoGenerateCheckinComment; clone.NoMerge = source.NoMerge; clone.OverrideReason = source.OverrideReason; clone.Force = source.Force; clone.OverrideGatedCheckIn = source.OverrideGatedCheckIn; clone.WorkItemsToAssociate.AddRange(source.WorkItemsToAssociate); clone.WorkItemsToResolve.AddRange(source.WorkItemsToResolve); clone.AuthorTfsUserId = source.AuthorTfsUserId; try { string re = globals.Repository.GetConfig(GitTfsConstants.WorkItemAssociateRegexConfigKey); if (String.IsNullOrEmpty(re)) clone.WorkItemAssociateRegex = GitTfsConstants.TfsWorkItemAssociateRegex; else clone.WorkItemAssociateRegex = new Regex(re); } catch (Exception) { clone.WorkItemAssociateRegex = null; } foreach (var note in source.CheckinNotes) { clone.CheckinNotes[note.Key] = note.Value; } return clone; }
public void Adds_work_item_to_resolve_and_removes_checkin_command_comment() { StringWriter textWriter = new StringWriter(); CommitSpecificCheckinOptionsFactory factory = new CommitSpecificCheckinOptionsFactory(textWriter); CheckinOptions singletonCheckinOptions = new CheckinOptions(); string commitMessage = @"test message formatted git commit message git-tfs-work-item: 1234 resolve"; string expectedCheckinComment = @"test message formatted git commit message "; var specificCheckinOptions = factory.BuildCommitSpecificCheckinOptions(singletonCheckinOptions, commitMessage); Assert.Equal(1, specificCheckinOptions.WorkItemsToResolve.Count); Assert.Contains("1234", specificCheckinOptions.WorkItemsToResolve); Assert.Equal(expectedCheckinComment.Replace(Environment.NewLine, "NEWLINE"), specificCheckinOptions.CheckinComment.Replace(Environment.NewLine, "NEWLINE")); }
public void Adds_work_item_to_associate_and_removes_checkin_command_comment() { StringWriter textWriter = new StringWriter(); CommitSpecificCheckinOptionsFactory factory = new CommitSpecificCheckinOptionsFactory(textWriter); CheckinOptions singletonCheckinOptions = new CheckinOptions(); string commitMessage = @"test message formatted git commit message git-tfs-work-item: 1234 associate"; string expectedCheckinComment = @"test message formatted git commit message "; var specificCheckinOptions = factory.BuildCommitSpecificCheckinOptions(singletonCheckinOptions, commitMessage); Assert.Equal(1, specificCheckinOptions.WorkItemsToAssociate.Count); Assert.Contains("1234", specificCheckinOptions.WorkItemsToAssociate); Assert.Equal(expectedCheckinComment, specificCheckinOptions.CheckinComment); }
public void Adds_reviewers_and_removes_checkin_command_comment() { StringWriter textWriter = new StringWriter(); CommitSpecificCheckinOptionsFactory factory = new CommitSpecificCheckinOptionsFactory(textWriter, new Globals()); CheckinOptions checkinOptions = new CheckinOptions(); string commitMessage = "Test message\n" + "\n" + "Some more information,\n" + "in a paragraph.\n" + "\n" + "git-tfs-code-reviewer: John Smith\n" + "git-tfs-security-reviewer: Teddy Knox\n" + "git-tfs-performance-reviewer: Liam Fasterson"; string expectedCheckinComment = "Test message\n" + "\n" + "Some more information,\n" + "in a paragraph."; var specificCheckinOptions = factory.BuildCommitSpecificCheckinOptions(checkinOptions, commitMessage); Assert.Equal(3, specificCheckinOptions.CheckinNotes.Count); Assert.Equal("John Smith", specificCheckinOptions.CheckinNotes["Code Reviewer"]); Assert.Equal("Teddy Knox", specificCheckinOptions.CheckinNotes["Security Reviewer"]); Assert.Equal("Liam Fasterson", specificCheckinOptions.CheckinNotes["Performance Reviewer"]); Assert.Equal(expectedCheckinComment, specificCheckinOptions.CheckinComment); }
private void ProcessCheckinNoteCommands(CheckinOptions checkinOptions, TextWriter writer) { foreach (Match match in GitTfsConstants.TfsReviewerRegex.Matches(checkinOptions.CheckinComment)) { string reviewer = match.Groups["reviewer"].Value; if (!string.IsNullOrWhiteSpace(reviewer)) { switch (match.Groups["type"].Value) { case "code": writer.WriteLine("Code reviewer: {0}", reviewer); checkinOptions.CheckinNotes.Add("Code Reviewer", reviewer); break; case "security": writer.WriteLine("Security reviewer: {0}", reviewer); checkinOptions.CheckinNotes.Add("Security Reviewer", reviewer); break; case "performance": writer.WriteLine("Performance reviewer: {0}", reviewer); checkinOptions.CheckinNotes.Add("Performance Reviewer", reviewer); break; } } } checkinOptions.CheckinComment = GitTfsConstants.TfsReviewerRegex.Replace(checkinOptions.CheckinComment, "").Trim(' ', '\r', '\n'); }
public Shelve(CheckinOptions checkinOptions, TfsWriter writer, Globals globals) { _globals = globals; _checkinOptions = checkinOptions; _checkinOptionsFactory = new CheckinOptionsFactory(_globals); _writer = writer; }
public Rcheckin(TextWriter stdout, CheckinOptions checkinOptions, TfsWriter writer, Globals globals) { _stdout = stdout; _checkinOptions = checkinOptions; _checkinOptionsFactory = new CommitSpecificCheckinOptionsFactory(_stdout, globals); _writer = writer; _globals = globals; }
public Shelve(TextWriter stdout, CheckinOptions checkinOptions, TfsWriter writer, Globals globals) { _stdout = stdout; _globals = globals; _checkinOptions = checkinOptions; _checkinOptionsFactory = new CheckinOptionsFactory(_stdout, _globals); _writer = writer; }
public Rcheckin(CheckinOptions checkinOptions, TfsWriter writer, Globals globals, AuthorsFile authors) { _checkinOptions = checkinOptions; _checkinOptionsFactory = new CheckinOptionsFactory(globals); _writer = writer; _globals = globals; _authors = authors; }
public Rcheckin(TextWriter stdout, CheckinOptions checkinOptions, TfsWriter writer, Globals globals, AuthorsFile authors) { _stdout = stdout; _checkinOptions = checkinOptions; _checkinOptionsFactory = new CheckinOptionsFactory(_stdout, globals); _writer = writer; _globals = globals; _authors = authors; }
public CheckinOptions BuildCommitSpecificCheckinOptions(CheckinOptions sourceCheckinOptions, string commitMessage, GitCommit commit, AuthorsFile authors) { var customCheckinOptions = BuildCommitSpecificCheckinOptions(sourceCheckinOptions, commitMessage); customCheckinOptions.ProcessAuthor(writer, commit, authors); return customCheckinOptions; }
public TfsWorkspace(IWorkspace workspace, string localDirectory, TextWriter stdout, TfsChangesetInfo contextVersion, IGitTfsRemote remote, CheckinOptions checkinOptions, ITfsHelper tfsHelper) { _workspace = workspace; _contextVersion = contextVersion; _remote = remote; _checkinOptions = checkinOptions; _tfsHelper = tfsHelper; _localDirectory = localDirectory; _stdout = stdout; }
public CheckinOptions BuildShelveSetSpecificCheckinOptions(CheckinOptions sourceCheckinOptions, string commitMessage) { var customCheckinOptions = sourceCheckinOptions.Clone(this.globals); customCheckinOptions.CheckinComment = commitMessage; customCheckinOptions.ProcessWorkItemCommands(writer, false); return customCheckinOptions; }
public CheckinOptions BuildCommitSpecificCheckinOptions(CheckinOptions sourceCheckinOptions, string commitMessage) { var customCheckinOptions = Clone(sourceCheckinOptions); customCheckinOptions.CheckinComment = commitMessage; ProcessWorkItemCommands(customCheckinOptions, writer); ProcessForceCommand(customCheckinOptions, writer); return customCheckinOptions; }
public CheckinOptions BuildCommitSpecificCheckinOptions(CheckinOptions sourceCheckinOptions, string commitMessage) { var customCheckinOptions = sourceCheckinOptions.Clone(_globals); customCheckinOptions.CheckinComment = commitMessage; customCheckinOptions.ProcessWorkItemCommands(); customCheckinOptions.ProcessCheckinNoteCommands(); customCheckinOptions.ProcessForceCommand(); return customCheckinOptions; }
private CheckinOptions Clone(CheckinOptions source) { CheckinOptions clone = new CheckinOptions(); clone.CheckinComment = source.CheckinComment; clone.NoGenerateCheckinComment = source.NoGenerateCheckinComment; clone.NoMerge = source.NoMerge; clone.OverrideReason = source.OverrideReason; clone.Force = source.Force; clone.OverrideGatedCheckIn = source.OverrideGatedCheckIn; clone.WorkItemsToAssociate.AddRange(source.WorkItemsToAssociate); clone.WorkItemsToResolve.AddRange(source.WorkItemsToResolve); return clone; }
public void Sets_commit_message_as_checkin_comments() { string originalCheckinComment = "command-line input"; var singletonCheckinOptions = new CheckinOptions { CheckinComment = originalCheckinComment }; string commitMessage = @"test message formatted git commit message"; var specificCheckinOptions = GetCheckinOptionsFactory().BuildCommitSpecificCheckinOptions(singletonCheckinOptions, commitMessage); Assert.Equal(commitMessage, specificCheckinOptions.CheckinComment); }
public void Checkin_failed() { IWorkspace workspace = MockRepository.GenerateStub<IWorkspace>(); string localDirectory = string.Empty; TextWriter writer = new StringWriter(); TfsChangesetInfo contextVersion = MockRepository.GenerateStub<TfsChangesetInfo>(); IGitTfsRemote remote = MockRepository.GenerateStub<IGitTfsRemote>(); remote.Repository = MockRepository.GenerateStub<IGitRepository>(); CheckinOptions checkinOptions = new CheckinOptions(); ITfsHelper tfsHelper = MockRepository.GenerateStub<ITfsHelper>(); CheckinPolicyEvaluator policyEvaluator = new CheckinPolicyEvaluator(); TfsWorkspace tfsWorkspace = new TfsWorkspace(workspace, localDirectory, writer, contextVersion, remote, checkinOptions, tfsHelper, policyEvaluator); IPendingChange pendingChange = MockRepository.GenerateStub<IPendingChange>(); IPendingChange[] allPendingChanges = new IPendingChange[] { pendingChange }; workspace.Stub(w => w.GetPendingChanges()).Return(allPendingChanges); ICheckinEvaluationResult checkinEvaluationResult = new StubbedCheckinEvaluationResult(); workspace.Stub(w => w.EvaluateCheckin( Arg<TfsCheckinEvaluationOptions>.Is.Anything, Arg<IPendingChange[]>.Is.Anything, Arg<IPendingChange[]>.Is.Anything, Arg<string>.Is.Anything, Arg<string>.Is.Anything, Arg<ICheckinNote>.Is.Anything, Arg<IEnumerable<IWorkItemCheckinInfo>>.Is.Anything)) .Return(checkinEvaluationResult); workspace.Expect(w => w.Checkin( Arg<IPendingChange[]>.Is.Anything, Arg<string>.Is.Anything, Arg<string>.Is.Anything, Arg<ICheckinNote>.Is.Anything, Arg<IEnumerable<IWorkItemCheckinInfo>>.Is.Anything, Arg<TfsPolicyOverrideInfo>.Is.Anything, Arg<bool>.Is.Anything)) .Return(0); var ex = Assert.Throws<GitTfsException>(() => { var result = tfsWorkspace.Checkin(checkinOptions); }); Assert.Equal("Checkin failed!", ex.Message); }
private void ProcessForceCommand(CheckinOptions checkinOptions, TextWriter writer) { MatchCollection workitemMatches; if ((workitemMatches = GitTfsConstants.TfsForceRegex.Matches(checkinOptions.CheckinComment)).Count == 1) { string overrideReason = workitemMatches[0].Groups["reason"].Value; if (!string.IsNullOrWhiteSpace(overrideReason)) { writer.WriteLine("Forcing the checkin: {0}", overrideReason); checkinOptions.Force = true; checkinOptions.OverrideReason = overrideReason; } checkinOptions.CheckinComment = GitTfsConstants.TfsForceRegex.Replace(checkinOptions.CheckinComment, "").Trim(' ', '\r', '\n'); } }
public CheckinOptions BuildShelveSetSpecificCheckinOptions(CheckinOptions sourceCheckinOptions, string commitMessage) { var customCheckinOptions = sourceCheckinOptions.Clone(this.globals); // Use commit message comment in call to ProcessWorkItemCommands customCheckinOptions.CheckinComment = commitMessage; customCheckinOptions.ProcessWorkItemCommands(writer, false); // This means a -m was provided. Override the shelveset comment with the -m value. if (!string.IsNullOrWhiteSpace(sourceCheckinOptions.CheckinComment)) { customCheckinOptions.CheckinComment = sourceCheckinOptions.CheckinComment; } return customCheckinOptions; }
public void Sets_commit_message_as_checkin_comments() { TextWriter writer = new StringWriter(); CommitSpecificCheckinOptionsFactory factory = new CommitSpecificCheckinOptionsFactory(writer); string originalCheckinComment = "command-line input"; CheckinOptions singletonCheckinOptions = new CheckinOptions() { CheckinComment = originalCheckinComment }; string commitMessage = @"test message formatted git commit message"; var specificCheckinOptions = factory.BuildCommitSpecificCheckinOptions(singletonCheckinOptions, commitMessage); Assert.Equal(commitMessage, specificCheckinOptions.CheckinComment); }
private CheckinOptions Clone(CheckinOptions source) { CheckinOptions clone = new CheckinOptions(); clone.CheckinComment = source.CheckinComment; clone.NoGenerateCheckinComment = source.NoGenerateCheckinComment; clone.NoMerge = source.NoMerge; clone.OverrideReason = source.OverrideReason; clone.Force = source.Force; clone.OverrideGatedCheckIn = source.OverrideGatedCheckIn; clone.WorkItemsToAssociate.AddRange(source.WorkItemsToAssociate); clone.WorkItemsToResolve.AddRange(source.WorkItemsToResolve); foreach (var note in source.CheckinNotes) { clone.CheckinNotes[note.Key] = note.Value; } return clone; }
public void Nothing_to_checkin() { IWorkspace workspace = MockRepository.GenerateStub<IWorkspace>(); string localDirectory = string.Empty; TfsChangesetInfo contextVersion = MockRepository.GenerateStub<TfsChangesetInfo>(); IGitTfsRemote remote = MockRepository.GenerateStub<IGitTfsRemote>(); remote.Repository = MockRepository.GenerateStub<IGitRepository>(); CheckinOptions checkinOptions = new CheckinOptions(); ITfsHelper tfsHelper = MockRepository.GenerateStub<ITfsHelper>(); CheckinPolicyEvaluator policyEvaluator = new CheckinPolicyEvaluator(); TfsWorkspace tfsWorkspace = new TfsWorkspace(workspace, localDirectory, contextVersion, remote, checkinOptions, tfsHelper, policyEvaluator); workspace.Stub(w => w.GetPendingChanges()).Return(null); var ex = Assert.Throws<GitTfsException>(() => { var result = tfsWorkspace.Checkin(checkinOptions); }); Assert.Equal("Nothing to checkin!", ex.Message); }
private void ProcessWorkItemCommands(CheckinOptions checkinOptions, TextWriter writer) { MatchCollection workitemMatches; if ((workitemMatches = GitTfsConstants.TfsWorkItemRegex.Matches(checkinOptions.CheckinComment)).Count > 0) { foreach (Match match in workitemMatches) { switch (match.Groups["action"].Value) { case "associate": writer.WriteLine("Associating with work item {0}", match.Groups["item_id"]); checkinOptions.WorkItemsToAssociate.Add(match.Groups["item_id"].Value); break; case "resolve": writer.WriteLine("Resolving work item {0}", match.Groups["item_id"]); checkinOptions.WorkItemsToResolve.Add(match.Groups["item_id"].Value); break; } } checkinOptions.CheckinComment = GitTfsConstants.TfsWorkItemRegex.Replace(checkinOptions.CheckinComment, "").Trim(' ', '\r', '\n'); } }
public Checkin(TextWriter stdout, CheckinOptions checkinOptions, TfsWriter writer) : base(stdout, checkinOptions, writer) { }
public Shelve(TextWriter stdout, CheckinOptions checkinOptions, TfsWriter writer) { _stdout = stdout; _checkinOptions = checkinOptions; _writer = writer; }
protected CheckinBase(TextWriter stdout, CheckinOptions checkinOptions, TfsWriter writer) { _stdout = stdout; _checkinOptions = checkinOptions; _writer = writer; }
protected CheckinBase(CheckinOptions checkinOptions, TfsWriter writer) { _checkinOptions = checkinOptions; _writer = writer; }
private int Checkin(string head, string parent, ITfsWorkspace workspace, CheckinOptions options, string sourceTfsPath) { PendChangesToWorkspace(head, parent, workspace); if (!string.IsNullOrWhiteSpace(sourceTfsPath)) workspace.Merge(sourceTfsPath, TfsRepositoryPath); return workspace.Checkin(options); }
public int Checkin(string head, string parent, TfsChangesetInfo parentChangeset, CheckinOptions options, string sourceTfsPath = null) { var changeset = 0; WithWorkspace(parentChangeset, workspace => changeset = Checkin(head, parent, workspace, options, sourceTfsPath)); return changeset; }
public void Shelve(string shelvesetName, string treeish, TfsChangesetInfo parentChangeset, CheckinOptions options, bool evaluateCheckinPolicies) { throw DerivedRemoteException; }
public Checkin(CheckinOptions checkinOptions, TfsWriter writer) : base(checkinOptions, writer) { }