public int Checkin(CheckinOptions options, Func <string> generateCheckinComment = null) { if (options == null) { options = _checkinOptions; } var checkinComment = options.CheckinComment; if (string.IsNullOrWhiteSpace(checkinComment) && !options.NoGenerateCheckinComment && generateCheckinComment != null) { checkinComment = generateCheckinComment(); } var pendingChanges = _workspace.GetPendingChanges(); if (pendingChanges.IsEmpty()) { throw new GitTfsException("Nothing to checkin!"); } var workItemInfos = GetWorkItemInfos(options); var checkinNote = _tfsHelper.CreateCheckinNote(options.CheckinNotes); var checkinProblems = _policyEvaluator.EvaluateCheckin(_workspace, pendingChanges, checkinComment, checkinNote, workItemInfos); if (checkinProblems.HasErrors) { bool overridePolicyErrors = options.Force && !string.IsNullOrWhiteSpace(options.OverrideReason); TraceCheckinPolicyErrors(checkinProblems, overridePolicyErrors); if (!options.Force) { throw new GitTfsException("No changes checked in."); } if (string.IsNullOrWhiteSpace(options.OverrideReason)) { throw new GitTfsException("A reason must be supplied (-f REASON) to override the policy violations."); } } var policyOverride = GetPolicyOverrides(options, checkinProblems.Result); try { var newChangeset = _workspace.Checkin(pendingChanges, checkinComment, options.AuthorTfsUserId, checkinNote, workItemInfos, policyOverride, options.OverrideGatedCheckIn); if (newChangeset == 0) { throw new GitTfsException("Checkin failed!"); } else { return(newChangeset); } } catch (GitTfsGatedCheckinException e) { return(LaunchGatedCheckinBuild(e.AffectedBuildDefinitions, e.ShelvesetName, e.CheckInTicket)); } }
public long Checkin(CheckinOptions options) { if (options == null) { options = _checkinOptions; } var pendingChanges = _workspace.GetPendingChanges(); if (pendingChanges.IsEmpty()) { throw new GitTfsException("Nothing to checkin!"); } var workItemInfos = GetWorkItemInfos(options); var checkinNote = _tfsHelper.CreateCheckinNote(options.CheckinNotes); var checkinProblems = _policyEvaluator.EvaluateCheckin(_workspace, pendingChanges, options.CheckinComment, checkinNote, workItemInfos); if (checkinProblems.HasErrors) { foreach (var message in checkinProblems.Messages) { if (options.Force && string.IsNullOrWhiteSpace(options.OverrideReason) == false) { _stdout.WriteLine("[OVERRIDDEN] " + message); } else { _stdout.WriteLine("[ERROR] " + message); } } if (!options.Force) { throw new GitTfsException("No changes checked in."); } if (String.IsNullOrWhiteSpace(options.OverrideReason)) { throw new GitTfsException("A reason must be supplied (-f REASON) to override the policy violations."); } } var policyOverride = GetPolicyOverrides(options, checkinProblems.Result); var newChangeset = _workspace.Checkin(pendingChanges, options.CheckinComment, options.AuthorTfsUserId, checkinNote, workItemInfos, policyOverride, options.OverrideGatedCheckIn); if (newChangeset == 0) { throw new GitTfsException("Checkin failed!"); } else { return(newChangeset); } }
public int Checkin(CheckinOptions options, Func <string> generateCheckinComment = null) { if (options == null) { options = _checkinOptions; } var checkinComment = options.CheckinComment; if (string.IsNullOrWhiteSpace(checkinComment) && !options.NoGenerateCheckinComment && generateCheckinComment != null) { checkinComment = generateCheckinComment(); } var pendingChanges = _workspace.GetPendingChanges(); if (pendingChanges.IsEmpty()) { throw new GitTfsException("Nothing to checkin!"); } var workItemInfos = GetWorkItemInfos(options); var checkinNote = _tfsHelper.CreateCheckinNote(options.CheckinNotes); var checkinProblems = _policyEvaluator.EvaluateCheckin(_workspace, pendingChanges, checkinComment, checkinNote, workItemInfos); if (checkinProblems.HasErrors) { foreach (var message in checkinProblems.Messages) { if (options.Force && string.IsNullOrWhiteSpace(options.OverrideReason) == false) { Trace.TraceWarning("[OVERRIDDEN] " + message); } else { Trace.TraceError("[ERROR] " + message); Trace.TraceInformation("Note: If the checkin policy fails because the assemblies failed to load, please run the file `enable_checkin_policies_support.bat` in the git-tfs directory and try again."); } } if (!options.Force) { throw new GitTfsException("No changes checked in."); } if (string.IsNullOrWhiteSpace(options.OverrideReason)) { throw new GitTfsException("A reason must be supplied (-f REASON) to override the policy violations."); } } var policyOverride = GetPolicyOverrides(options, checkinProblems.Result); try { var newChangeset = _workspace.Checkin(pendingChanges, checkinComment, options.AuthorTfsUserId, checkinNote, workItemInfos, policyOverride, options.OverrideGatedCheckIn); if (newChangeset == 0) { throw new GitTfsException("Checkin failed!"); } else { return(newChangeset); } } catch (GitTfsGatedCheckinException e) { return(LaunchGatedCheckinBuild(e.AffectedBuildDefinitions, e.ShelvesetName, e.CheckInTicket)); } }