public GetTrackRoot ( |
||
trackItem | ||
return | string |
static void ProcessHistoryInternal(DXVcsWrapper vcsWrapper, GitWrapper gitWrapper, RegisteredUsers users, User defaultUser, string localGitDir, TrackBranch branch, IList<CommitItem> commits, SyncHistoryWrapper syncHistory) { ProjectExtractor extractor = new ProjectExtractor(commits, (item) => { var localCommits = vcsWrapper.GetCommits(item.TimeStamp, item.Items).Where(x => !IsLabel(x)).ToList(); bool hasModifications = false; GitCommit last = null; string token = syncHistory.CreateNewToken(); foreach (var localCommit in localCommits) { string localProjectPath = Path.Combine(localGitDir, localCommit.Track.ProjectPath); DirectoryHelper.DeleteDirectory(localProjectPath); string trackPath = branch.GetTrackRoot(localCommit.Track); vcsWrapper.GetProject(vcsServer, trackPath, localProjectPath, item.TimeStamp); Log.Message($"git stage {localCommit.Track.ProjectPath}"); gitWrapper.Stage(localCommit.Track.ProjectPath); string author = CalcAuthor(localCommit, defaultUser); var comment = CalcComment(localCommit, author, token); User user = users.GetUser(author); try { gitWrapper.Commit(comment.ToString(), user, localCommit.TimeStamp, false); last = gitWrapper.FindCommit(x => true); hasModifications = true; } catch (Exception) { Log.Message($"Empty commit detected for {localCommit.Author} {localCommit.TimeStamp}."); } } if (hasModifications) { gitWrapper.PushEverything(); syncHistory.Add(last.Sha, item.TimeStamp.Ticks, token); } else { var head = syncHistory.GetHead(); syncHistory.Add(head.GitCommitSha, item.TimeStamp.Ticks, token); string author = CalcAuthor(item, defaultUser); Log.Message($"Push empty commits rejected for {author} {item.TimeStamp}."); } syncHistory.Save(); }); int i = 0; while (extractor.PerformExtraction()) Log.Message($"{++i} from {commits.Count} push to branch {branch.Name} completed."); }
public IList<TrackItem> GenerateTrackItems(TrackBranch trackBranch, TrackItem trackItem) { if (!trackItem.GoDeeper) return new List<TrackItem>() {trackItem}; try { var repo = DXVcsConnectionHelper.Connect(server, user, password); string trackRoot = trackBranch.GetTrackRoot(trackItem); var projectData = repo.GetProjectData(trackRoot); if (projectData.IsNull || projectData.SubProjectsCount == 0) return new List<TrackItem>() {trackItem}; var innerProjects = repo.GetProjects(trackRoot); if (innerProjects == null || innerProjects.Length == 0) return new List<TrackItem>() { trackItem }; List<TrackItem> result = new List<TrackItem>(innerProjects.Length); foreach (var info in innerProjects) { var newTrackItem = new TrackItem(); newTrackItem.Branch = trackBranch.Name; newTrackItem.GoDeeper = false; newTrackItem.Path = trackItem.Path + @"/" + info.Name; newTrackItem.ProjectPath = Path.Combine(trackItem.ProjectPath, info.Name).Replace(@"\", @"/"); newTrackItem.AdditionalOffset = trackItem.AdditionalOffset; result.Add(newTrackItem); } return result; } catch(Exception ex) { Log.Error("Generating trackitems from config failed", ex); throw ex; } }
static string CalcVcsPath(TrackBranch branch, string path) { var root = path.Split(new[] { @"\", @"/" }, StringSplitOptions.RemoveEmptyEntries).FirstOrDefault(); var trackItem = branch.TrackItems.First(x => root == x.ProjectPath); var resultPath = path.Remove(0, trackItem.ProjectPath.Length).TrimStart(@"\/".ToCharArray()); string trackPath = branch.GetTrackRoot(trackItem); return Path.Combine(trackPath, resultPath).Replace("\\", "/"); }
public IList<HistoryItem> GenerateHistory(TrackBranch branch, DateTime from) { try { var repo = DXVcsConnectionHelper.Connect(server, user, password); var history = Enumerable.Empty<HistoryItem>(); foreach (var trackItem in branch.TrackItems) { string trackPath = branch.GetTrackRoot(trackItem); var historyForItem = repo.GetProjectHistory(trackPath, true, from).Select(x => new HistoryItem() { ActionDate = x.ActionDate, Comment = x.Comment, Label = x.Label, Message = x.Message, Name = x.Name, User = x.User, Track = trackItem, }); history = history.Concat(historyForItem); } return history.ToList(); } catch (Exception ex) { Log.Error("History generation failed.", ex); throw; } }