/// <summary> /// Gets the modifications. /// </summary> /// <param name="from">From.</param> /// <param name="to">To.</param> /// <returns></returns> /// <remarks></remarks> public override Modification[] GetModifications(IIntegrationResult from, IIntegrationResult to) { // fetch latest changes from the remote repository RepositoryAction result = CreateUpateLocalRepository(to); Dictionary <string, string> revisionData = NameValuePair.ToDictionary(from.SourceControlData); ProcessResult logResult; string lastCommit; if (revisionData.TryGetValue(COMMIT_KEY, out lastCommit)) { logResult = GitLogHistory(GetBranchNameOrRevision(Branch, Revision), lastCommit, to); } else { Log.Debug(string.Concat("[Git] last integrated commit not found, using all ancestors of ", GetBranchNameOrRevision(Branch, Revision), " as the set of modifications.")); logResult = GitLogHistory(GetBranchNameOrRevision(Branch, Revision), to); } // Get the hash of the origin head, and store it against the integration result. string originHeadHash = GitLogOriginHash(GetBranchNameOrRevision(Branch, Revision), to); revisionData[COMMIT_KEY] = originHeadHash; to.SourceControlData.Clear(); NameValuePair.Copy(revisionData, to.SourceControlData); return(ParseModifications(logResult, lastCommit)); }
/// <summary> /// Starts the new integration. /// </summary> /// <param name="request">The request.</param> /// <returns></returns> /// <remarks></remarks> public IIntegrationResult StartNewIntegration(IntegrationRequest request) { IntegrationResult newResult = new IntegrationResult(project.Name, project.WorkingDirectory, project.ArtifactDirectory, request, LastIntegration); newResult.ArtifactDirectory = project.ArtifactDirectory; newResult.ProjectUrl = project.WebURL; NameValuePair.Copy(LastIntegrationResult.SourceControlData, newResult.SourceControlData); return(currentIntegration = newResult); }
/// <summary> /// Gets the modifications. /// </summary> /// <param name="from">From.</param> /// <param name="to">To.</param> /// <returns></returns> /// <remarks></remarks> public override Modification[] GetModifications(IIntegrationResult from, IIntegrationResult to) { var revisionData = NameValuePair.ToDictionary(from.SourceControlData); if (to.LastIntegrationStatus == IntegrationStatus.Unknown) { ((SvnHistoryParser)historyParser).IntegrationStatusUnknown = true; } string wd = Path.GetFullPath(to.BaseFromWorkingDirectory(WorkingDirectory)); if (WorkingFolderIsKnownAsSvnWorkingFolder(wd)) { if (CleanUp) { Execute(CleanupWorkingCopy(to)); } if (Revert) { Execute(RevertWorkingCopy(to)); } if (this.DeleteObstructions) { this.DeleteObstructionsFromWorking(to); } } else { Util.Log.Warning(string.Format(System.Globalization.CultureInfo.CurrentCulture, "{0} is not a svn working folder", wd)); } List <Modification> modifications = new List <Modification>(); List <string> repositoryUrls = new List <string>(); repositoryUrls.Add(TrunkUrl); if (CheckExternals) { ProcessResult resultOfSvnPropget = Execute(PropGetProcessInfo(to)); List <string> externals = ParseExternalsDirectories(resultOfSvnPropget); foreach (string external in externals) { if (!repositoryUrls.Contains(external)) { repositoryUrls.Add(external); } } } foreach (string repositoryUrl in repositoryUrls) { var lastRepositoryRevisionName = "SVN:LastRevision:" + repositoryUrl; Modification[] modsInRepository; string lastRepositoryRevision = null; if (UseRevsionNumbers) { // Since we are using the last revision number, see if there is any number stored to use lastRepositoryRevision = revisionData.ContainsKey(lastRepositoryRevisionName) ? revisionData[lastRepositoryRevisionName] : null; ProcessResult result = Execute(NewHistoryProcessInfoFromRevision(lastRepositoryRevision, to, repositoryUrl)); modsInRepository = ParseModifications(result, lastRepositoryRevision); } else { // Use use the date range ProcessResult result = Execute(NewHistoryProcessInfo(from, to, repositoryUrl)); modsInRepository = ParseModifications(result, from.StartTime, to.StartTime); } // If there are modifications, get the number and add them to the output if (modsInRepository != null) { lastRepositoryRevision = Modification.GetLastChangeNumber(modsInRepository) ?? lastRepositoryRevision; modifications.AddRange(modsInRepository); revisionData[lastRepositoryRevisionName] = lastRepositoryRevision; } // Set the latest revision - this always need to be done just in case an external has triggered a build if (repositoryUrl == TrunkUrl) { latestRevision = int.Parse(lastRepositoryRevision ?? "0", CultureInfo.CurrentCulture); revisionData[lastRepositoryRevisionName] = lastRepositoryRevision; } } mods = modifications.ToArray(); if (UrlBuilder != null) { UrlBuilder.SetupModification(mods); } FillIssueUrl(mods); // Store the latest revision number to.SourceControlData.Clear(); NameValuePair.Copy(revisionData, to.SourceControlData); return(mods); }
public override Modification[] GetModifications(IIntegrationResult from, IIntegrationResult to) { Dictionary <string, string> dictionary = NameValuePair.ToDictionary(from.SourceControlData); IList <Modification> changeList = new List <Modification>(); InitProcessData(to); InitGitRepository(to); git.Reset(to, Branch); git.Reset(to, StartBranch); git.FetchOrigin(to); // StartBranch git.Checkout(to, StartBranch); var diffOriginStartBranch = git.GetDiffList(to, $"origin/{StartBranch}"); var startBranchPullResult = git.Pull(to); foreach (var item in startBranchPullResult.Item2) { changeList.Add(item); } // Branch git.Checkout(to, Branch); var diffOriginBranch = git.GetDiffList(to, $"origin/{Branch}"); var branchPullResult = git.Pull(to); foreach (var item in branchPullResult.Item2) { changeList.Add(item); } if (changeList.Count == 0 && from.LastBuildStatus != IntegrationStatus.Success) { foreach (var change in from.Modifications) { changeList.Add(change); } } if (isFirstRun || from.LastBuildStatus != IntegrationStatus.Success) { if (changeList.Count == 0) { changeList.Add(new Modification { ChangeNumber = "Initialize", Comment = "Initialize", FileName = "", FolderName = "", ModifiedTime = DateTime.MinValue, EmailAddress = "Initialize", UserName = "******", Type = "Unmodified" }); } } to.SourceControlData.Clear(); NameValuePair.Copy(dictionary, to.SourceControlData); to.SetSourceData("$TqGitCI_repository", gitUrl); to.SetSourceData("$TqGitCI_gitDirectory", gitDirectory); to.SetSourceData("$TqGitCI_branch", Branch); to.SetSourceData("$TqGitCI_startBranch", StartBranch); to.SetSourceData("$TqGitCI_projectName", projectName); to.SetSourceData("$TqGitCI_hasDiffOrigin1", (diffOriginBranch.Count > 0).ToString()); to.SetSourceData("$TqGitCI_pullResult1", branchPullResult.Item1.Status.ToString()); to.SetSourceData("$TqGitCI_lastCommitter1", branchPullResult.Item2.LastOrDefault()?.UserName ?? string.Empty); to.SetSourceData("$TqGitCI_hasDiffOrigin2", (diffOriginStartBranch.Count > 0).ToString()); to.SetSourceData("$TqGitCI_pullResult2", startBranchPullResult.Item1.Status.ToString()); to.SetSourceData("$TqGitCI_lastCommitter2", startBranchPullResult.Item2.LastOrDefault()?.UserName ?? string.Empty); to.SetParameters("$TqGitCI_gitUserId", GitUserId); to.SetParameters("$TqGitCI_gitUserPassword", GitUserPassword); return(changeList.ToArray()); }