public MergeRequestFileDataViewModel(MergeRequestFileData fileData)
 {
     this.fileData = fileData;
     ChangeMode = CalcChangeMode();
     Path = fileData.OldPath;
     Diff = fileData.Diff;
 }
Beispiel #2
0
 static SyncItem ProcessMergeRequestChanges(MergeRequest mergeRequest, MergeRequestFileData fileData, string localGitDir, TrackBranch branch, string token) {
     string vcsRoot = branch.RepoRoot;
     var syncItem = new SyncItem();
     if (fileData.IsNew) {
         syncItem.SyncAction = SyncAction.New;
         syncItem.LocalPath = CalcLocalPath(localGitDir, branch, fileData.OldPath);
         syncItem.VcsPath = CalcVcsPath(branch, fileData.OldPath);
     }
     else if (fileData.IsDeleted) {
         syncItem.SyncAction = SyncAction.Delete;
         syncItem.LocalPath = CalcLocalPath(localGitDir, branch, fileData.OldPath);
         syncItem.VcsPath = CalcVcsPath(branch, fileData.OldPath);
     }
     else if (fileData.IsRenamed) {
         syncItem.SyncAction = SyncAction.Move;
         syncItem.LocalPath = CalcLocalPath(localGitDir, branch, fileData.OldPath);
         syncItem.NewLocalPath = CalcLocalPath(localGitDir, branch, fileData.NewPath);
         syncItem.VcsPath = CalcVcsPath(branch, fileData.OldPath);
         syncItem.NewVcsPath = CalcVcsPath(branch, fileData.NewPath);
     }
     else {
         syncItem.SyncAction = SyncAction.Modify;
         syncItem.LocalPath = CalcLocalPath(localGitDir, branch, fileData.OldPath);
         syncItem.VcsPath = CalcVcsPath(branch, fileData.OldPath);
     }
     syncItem.Comment = CalcComment(mergeRequest, branch, token);
     return syncItem;
 }
Beispiel #3
0
 static bool ValidateFileChange(MergeRequestFileData diff) {
     if (!CheckFilesList.Contains(Path.GetExtension(diff.OldPath)))
         return true;
     var fixeol = diff.Diff.Replace("\n\\ No newline at end of file\n", Environment.NewLine);
     var chunks = fixeol.Split(new[] { '\n' }, StringSplitOptions.RemoveEmptyEntries);
     return chunks.Where(x => NewlinePattern.IsMatch(x)).Select(chunk => chunk.ToCharArray()).All(charArray => charArray.LastOrDefault() == '\r');
 }
Beispiel #4
0
 static bool CheckItemForChangeSet(MergeRequestFileData x, TrackItem track) {
     var root = x.OldPath.Split(new[] { @"\", @"/" }, StringSplitOptions.RemoveEmptyEntries).FirstOrDefault();
     return root == track.ProjectPath;
 }
Beispiel #5
0
 static SyncAction CalcSyncAction(MergeRequestFileData fileData) {
     if (fileData.IsDeleted)
         return SyncAction.Delete;
     if (fileData.IsNew)
         return SyncAction.New;
     if (fileData.IsRenamed)
         return SyncAction.Move;
     return SyncAction.Modify;
 }