Beispiel #1
0
        public async Task UseBaseAsync(CommitFile file)
        {
            CleanTempPaths(file);
            await UseFileAsync(file, file.Conflict.BaseId);

            await ResolveAsync(file.Path, file.FullFilePath);
        }
Beispiel #2
0
        private bool HasConflicts(CommitFile file)
        {
            string fullPath = Path.Combine(workingFolder, file.Path);

            return
                (File.Exists(fullPath) &&
                 File.ReadAllLines(fullPath).Any(line => line.StartsWith(ConflictMarker)));
        }
 private CommitFileViewModel ToCommitFileViewModel(string workingFolder, CommitFile file)
 {
     return(new CommitFileViewModel(diffService, themeService, file, UndoUncommittedFileCommand)
     {
         WorkingFolder = workingFolder,
         Id = CommitSha.Uncommitted,
         Name = file.Path,
         Status = file.StatusText
     });
 }
Beispiel #4
0
        public async Task DeleteAsync(CommitFile file)
        {
            await Task.Yield();

            CleanTempPaths(file);
            string fullPath = file.FullFilePath;

            DeletePath(fullPath);

            await ResolveAsync(file.Path, file.FullFilePath);
        }
Beispiel #5
0
 public CommitFileViewModel(
     IDiffService diffService,
     IThemeService themeService,
     CommitFile file,
     Command <string> undoUncommittedFileCommand)
 {
     this.diffService           = diffService;
     this.themeService          = themeService;
     this.file                  = file;
     UndoUncommittedFileCommand = undoUncommittedFileCommand.With(() => Name);
 }
Beispiel #6
0
        public async Task ShowYourDiffAsync(CommitFile file)
        {
            string yoursPath = GetPath(file, Theirs);
            string basePath  = GetPath(file, Base);

            await GetFileAsync(file.Conflict.LocalId, yoursPath);
            await GetFileAsync(file.Conflict.BaseId, basePath);

            if (File.Exists(yoursPath) && File.Exists(basePath))
            {
                await ShowDiffImplAsync(basePath, yoursPath);

                DeletePath(basePath);
                DeletePath(yoursPath);
            }
        }
Beispiel #7
0
        public async Task ShowTheirDiffAsync(CommitFile file)
        {
            string basePath   = GetPath(file, Base);
            string theirsPath = GetPath(file, Theirs);

            await GetFileAsync(file.Conflict.BaseId, basePath);
            await GetFileAsync(file.Conflict.RemoteId, theirsPath);

            if (File.Exists(theirsPath) && File.Exists(basePath))
            {
                await ShowDiffImplAsync(basePath, theirsPath);

                DeletePath(basePath);
                DeletePath(theirsPath);
            }
        }
Beispiel #8
0
        static void Main(string[] args)
        {
            var commitLineBuilderFactory = new CommitLineBuilderFactory(
                new CommentLineBuilder(),
                new NoOpLineBuilder(),
                new FixupLineBuilder(),
                new PickLineBuilder(),
                new RewordLineBuilder(),
                new SquashLineBuilder(),
                new EditLineBuilder()
                );
            var lines = File.ReadAllLines(args[0]);
            var file = new CommitFile(lines, commitLineBuilderFactory);

            var commits = file.GetCommits();

            commits.Select(x => x.Line).ForEach(Console.WriteLine);
            Console.ReadKey();
        }
Beispiel #9
0
        public async Task MergeConflictsAsync(CommitSha commitSha, CommitFile file)
        {
            CleanTempPaths(file);

            string basePath   = GetPath(file, Base);
            string yoursPath  = GetPath(file, Yours);
            string theirsPath = GetPath(file, Theirs);

            await GetFileAsync(file.Conflict.LocalId, yoursPath);
            await GetFileAsync(file.Conflict.RemoteId, theirsPath);
            await GetFileAsync(file.Conflict.BaseId, basePath);

            if (File.Exists(yoursPath) && File.Exists(theirsPath) && File.Exists(basePath))
            {
                await ShowMergeImplAsync(theirsPath, yoursPath, basePath, file.FullFilePath);

                if (!HasConflicts(file))
                {
                    await ResolveAsync(file.Path, file.FullFilePath);
                }
            }

            CleanTempPaths(file);
        }
Beispiel #10
0
        private void CommitHistory()
        {
            Database   db = new Database();
            Repository repo;
            //List<Entities.Commit> commiList
            //Entities.Commit commit;
            //CommitFile commitFile;
            NotificationArgs notificationArgs;

            var directories = Directory.GetDirectories(downloadDirectory);

            int counter   = 0;
            int groupSize = Convert.ToInt32(Math.Ceiling(directories.Count() / 3.0));

            var result      = directories.GroupBy(s => counter++ / groupSize).Select(g => g.ToArray()).ToList();
            int threadCount = result.Count() + 1;

            Parallel.For(0, threadCount, i =>
            {
                var dataSet = result.ElementAtOrDefault(i);
                if (dataSet != null)
                {
                    Console.WriteLine("Processing dataset: " + i + "; Count: " + dataSet.Count());
                    foreach (var directory in dataSet)
                    {
                        string lastFolderName = Path.GetFileName(directory);
                        long appId            = db.GetAppByName(lastFolderName).Id;
                        try
                        {
                            repo = new Repository(directory);
                            List <Entities.Commit> commiList = new List <Entities.Commit>();

                            int commitCount = repo.Commits.Count();

                            notificationArgs = new NotificationArgs(string.Format("Started - Commit Histroy for {0} - Total Commits: {1}", lastFolderName, commitCount), DateTime.Now, NotificationType.INFORMATION);
                            OnMessageIssued(notificationArgs);

                            int j = repo.Commits.Count() - 1;
                            foreach (var cx in repo.Commits)
                            // for (int i = commitCount - 1; i >= 0; i--)
                            {
                                Entities.Commit commit = new Entities.Commit();
                                commit.AuthorEmail     = cx.Author.Email;
                                commit.AuthorEmail     = cx.Author.Email;
                                commit.AuthorName      = cx.Author.Name;
                                commit.Date            = cx.Author.When.LocalDateTime;
                                commit.Message         = cx.Message;
                                commit.GUID            = cx.Sha;

                                if (includeFiles)
                                {
                                    if (j == commitCount - 1)
                                    {
                                        Tree firstCommit = repo.Lookup <Tree>(repo.Commits.ElementAt(j).Tree.Sha);
                                        Tree lastCommit  = repo.Lookup <Tree>(repo.Commits.ElementAt(0).Tree.Sha);

                                        var changes = repo.Diff.Compare <TreeChanges>(lastCommit, firstCommit);
                                        foreach (var item in changes)
                                        {
                                            if (item.Status != ChangeKind.Deleted)
                                            {
                                                CommitFile commitFile = new CommitFile(item.Path, ChangeKind.Added.ToString());
                                                commit.CommitFiles.Add(commitFile);
                                            }
                                        }
                                    }
                                    else
                                    {
                                        var changes = repo.Diff.Compare <TreeChanges>(repo.Commits.ElementAt(j + 1).Tree, repo.Commits.ElementAt(j).Tree);
                                        foreach (var item in changes)
                                        {
                                            CommitFile commitFile = new CommitFile(item.Path, item.Status.ToString());
                                            commit.CommitFiles.Add(commitFile);
                                        }
                                    }
                                }

                                commiList.Add(commit);

                                j--;
                            }

                            db.BatchInsertCommits(commiList, appId);

                            notificationArgs = new NotificationArgs(string.Format("Completed - Commit Histroy for {0}", lastFolderName), DateTime.Now, NotificationType.SUCCESS);
                            OnMessageIssued(notificationArgs);
                        }
                        catch (Exception error)
                        {
                            LogFailure(string.Format("Failed - Commit Histroy for {0} ; {1}", lastFolderName, error.Message));
                            notificationArgs = new NotificationArgs("Failed -  Commit Histroy for " + lastFolderName, DateTime.Now, NotificationType.FAILURE);
                            OnMessageIssued(notificationArgs);
                            continue;
                        }
                    }
                }
            });
        }
Beispiel #11
0
 public bool CanMergeConflict(CommitFile file) =>
 file.Status.HasFlag(GitFileStatus.ConflictMM) ||
 file.Status.HasFlag(GitFileStatus.ConflictAA);
Beispiel #12
0
 public bool CanUseYours(CommitFile file) => !file.Status.HasFlag(GitFileStatus.ConflictDM);
Beispiel #13
0
 private string GetPath(CommitFile file, string type)
 {
     return(GetConflictTypePath(file.FullFilePath, type));
 }
Beispiel #14
0
 private async Task UseFileAsync(CommitFile file, string fileId)
 {
     await GetFileAsync(fileId, file.FullFilePath);
 }
Beispiel #15
0
 private void CleanTempPaths(CommitFile file)
 {
     DeletePath(GetPath(file, Base));
     DeletePath(GetPath(file, Yours));
     DeletePath(GetPath(file, Theirs));
 }
Beispiel #16
0
 public bool CanDelete(CommitFile file)
 {
     return(file.Status.HasFlag(GitFileStatus.Conflict));
 }
Beispiel #17
0
 public bool CanUseTheirs(CommitFile file) => !file.Status.HasFlag(GitFileStatus.ConflictMD);
Beispiel #18
0
 public bool CanUseBase(CommitFile file) => !file.Status.HasFlag(GitFileStatus.ConflictAA);