예제 #1
0
        public void CloneRepository(string path)
        {
            RepositoryClosed();
            TabManager.AddMainTab();
            var v = LibGitService.GetInstance().IsValidRepository(path);

            if (v != RepositoryValidation.Invalid)
            {
                TabManager.CloseAll();
                MessageBox.Show("There is already a repository", "", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }
            var dialog = new InputDialog()
            {
                Text = "Enter clone url", Validator = text => true, Owner = Application.Current.MainWindow
            };
            var ans = dialog.ShowDialog();

            if (ans == null || ans == false)
            {
                return;
            }
            v = RepositoryManager.Clone(path, dialog.ResponseText);
            if (v != RepositoryValidation.Valid)
            {
                TabManager.CloseAll();
            }
            else
            {
                Graph.GetInstance().ResetTranslate();
            }
        }
예제 #2
0
        void DeployBranchNodes()
        {
            List <BranchLabelModel> branchModels = new List <BranchLabelModel>();

            ZoomAndPanCanvasModel.Branches?.ToList().ForEach(b => UnsubscribeEvents(b));
            Dictionary <Commit, CommitNodeModel> pairs        = ZoomAndPanCanvasModel.Commits.ToDictionary(x => x.Commit);
            List <IGrouping <Commit, Branch> >   branchGroups = LibGitService.GetInstance().Branches.GroupBy(b => b.Tip).ToList();

            foreach (var branchGroup in branchGroups)
            {
                int y = 1;
                List <BranchLabelModel> mg = branchGroup.ToList().Select(b =>
                {
                    CommitNodeModel tipNode = pairs[b.Tip];
                    tipNode.PlusButton      = false;
                    Point cl           = tipNode.Location;
                    BranchLabelModel m = new BranchLabelModel()
                    {
                        Location = new Point(cl.X, cl.Y - 10 - 32 * (y++)), Branch = b
                    };
                    branchModels.Add(m);
                    return(m);
                }).ToList();
                mg.First().Arrow     = true;
                mg.Last().PlusButton = true;
            }
            branchModels.ForEach(b => SubscribeEvents(b));
            ZoomAndPanCanvasModel.Branches = branchModels;
        }
예제 #3
0
        void Old()
        {
            Hashtable branchCommits = LibGitService.GetInstance().BranchCommits();
            int       y             = 0;

            ZoomAndPanCanvasModel.Commits?.ToList().ForEach(c => UnsubscribeCommitEvents(c));
            List <CommitNodeModel> models = new List <CommitNodeModel>();

            foreach (Branch b in branchCommits.Keys)
            {
                int                    x       = 0;
                List <Commit>          l       = (List <Commit>)branchCommits[b];
                List <CommitNodeModel> commits = l?.Select(c =>
                {
                    Identity i          = new Identity(c.Author.Name, c.Author.Email);
                    BitmapImage picture = Program.GetInstance().UserManager.FindUserPictureByIdentity(i);
                    return(new CommitNodeModel(c, picture));
                }).ToList();
                commits.Reverse();
                commits.ForEach(c => c.Location = new System.Windows.Point((x++) * 250, y));
                commits.ForEach(c => models.Add(c));
                y += 50;
            }
            models.ForEach(c => SubscribeCommitEvents(c));
            ZoomAndPanCanvasModel.Commits = models;
        }
예제 #4
0
        void  DeployCommitNodes()
        {
            var inProgress = Program.GetInstance().StashingManager.ImplicitStashBases;
            var commitRows = LibGitService.GetInstance().CommitRows();

            ZoomAndPanCanvasModel.Commits?.ToList().ForEach(c => UnsubscribeCommitEvents(c));
            List <CommitNodeModel> commitModels = new List <CommitNodeModel>();
            int x = 0;
            List <CommitNodeModel> commits = commitRows.Select(pair =>
            {
                Commit c            = pair.Item1;
                BitmapImage picture = null;
                if (c.Author.Name != "" && c.Author.Email != "")
                {
                    Identity i = new Identity(c.Author.Name, c.Author.Email);
                    picture    = Program.GetInstance().UserManager.FindUserPictureByIdentity(i);
                }
                CommitNodeModel m = new CommitNodeModel(c, picture)
                {
                    Location = new Point(x, pair.Item2 * 70)
                };
                x += (int)m.MaxWidth + 150;
                if (inProgress != null && inProgress.Contains(c))
                {
                    m.InProgress = true;
                }
                return(m);
            }).ToList();

            commits.ForEach(c => commitModels.Add(c));
            commitModels.ForEach(c => SubscribeCommitEvents(c));
            ZoomAndPanCanvasModel.Commits = commitModels;
        }
예제 #5
0
 public static LibGitService GetInstance()
 {
     if (_instance == null)
     {
         _instance = new LibGitService();
     }
     return(_instance);
 }
예제 #6
0
 public StashingManager(string dataFolder)
 {
     _dirPath = Path.Combine(dataFolder, "ImplicitStashes");
     LibGitService.GetInstance().RepositoryChanged += UpdateStashWindow;
     LibGitService.GetInstance().BranchChanged     += ImplicitPop;
     StashMenu.StashApplyed += Apply;
     StashMenu.StashDeleted += RemoveStash;
     StashMenu.StashPopped  += Pop;
 }
예제 #7
0
 void SetupRepository()
 {
     CurrentRepository          = LibGitService.GetInstance().Repository;
     CurrentRepositoryDirectory = FindRepositoryLogPathIfExists();
     if (CurrentRepositoryDirectory == null)
     {
         CurrentRepositoryDirectory = CreateRepositoryLog();
     }
 }
예제 #8
0
 void SelectDiff(int index)
 {
     if (index < 0 || !Commit.Commit.Parents.Any())
     {
         return;
     }
     SelectedCommit = Commit.Commit.Parents.ToList()[index];
     CommitChanges  = LibGitService.GetInstance().CommitChanges(Commit.Commit, SelectedCommit);
     RepositoryStatusChanged?.Invoke();
 }
예제 #9
0
        public void OnAddBranch(GraphItemModel m)
        {
            var dialog = new InputDialog();

            dialog.Validator = text => Logic.LibGitService.GetInstance().IsValidRefName(text);
            dialog.Text      = "Enter name of new branch";
            if (dialog.ShowDialog() == true)
            {
                LibGitService.GetInstance().Branch(m, dialog.ResponseText);
            }
        }
예제 #10
0
        public void Rebase(BranchLabelModel rebasing, BranchLabelModel rebased)
        {
            GraphItemModel checkouted = Graph.Checkouted;

            Checkout(rebasing);
            bool succes = LibGitService.Merge(rebased);

            if (succes)
            {
                Checkout(rebased);
            }
        }
예제 #11
0
        public void Merge(BranchLabelModel merging, BranchLabelModel merged)
        {
            GraphItemModel checkouted = Graph.Checkouted;

            Checkout(merging);
            bool succes = LibGitService.Merge(merged);

            if (succes)
            {
                Checkout(checkouted);
            }
        }
예제 #12
0
 public void CheckConflicts()
 {
     _conflict = LibGitService.GetInstance().IsInConflictState;
     if (_conflict)
     {
         ActionsManager.TurnConflictState();
         TabManager.TurnConflictState();
     }
     else
     {
         ActionsManager.TurnNoConflictState();
         TabManager.TurnNoConflictState();
     }
 }
예제 #13
0
 bool OpenValid(string path)
 {
     if (LibGitService.GetInstance().Size(path) > 10000)
     {
         var result = MessageBox.Show("Opening repository with more than 10000 commits is not recommended due to slow redrawing. Do you want to open the repository anyways?", "", MessageBoxButton.YesNo, MessageBoxImage.Warning);
         if (result == MessageBoxResult.No)
         {
             return(false);
         }
     }
     LibGitService.GetInstance().OpenRepository(path);
     if (LibGitService.GetInstance().Repository != null)
     {
         return(Open(path));
     }
     return(true);
 }
예제 #14
0
        void UpdateCheckouted()
        {
            Branch           head             = LibGitService.GetInstance().Head;
            BranchLabelModel checkoutedBranch = ZoomAndPanCanvasModel.Branches.Find(b => b.Branch.CanonicalName == head.CanonicalName);

            if (checkoutedBranch != null)
            {
                HighlightAsCheckouted(checkoutedBranch);
            }
            else
            {
                CommitNodeModel checkoutedCommit = ZoomAndPanCanvasModel.Commits.Find(c => c.Sha == head.Reference.TargetIdentifier);
                if (checkoutedCommit != null)
                {
                    HighlightAsCheckouted(checkoutedCommit);
                }
            }
        }
예제 #15
0
        public bool OpenRecent(string path)
        {
            var v = LibGitService.GetInstance().IsValidRepository(path);

            if (v == RepositoryValidation.Valid)
            {
                return(OpenValid(path));
            }
            else if (v == RepositoryValidation.Invalid)
            {
                PromptDelete(path);
            }
            else
            {
                InfoBare();
            }
            return(false);
        }
예제 #16
0
        public bool OpenExisting(string path)
        {
            var v = LibGitService.GetInstance().IsValidRepository(path);

            if (v == RepositoryValidation.Valid)
            {
                return(OpenValid(path));
            }
            else if (v == RepositoryValidation.Invalid)
            {
                return(PromptCreatingNew(path));
            }
            else
            {
                InfoBare();
            }
            return(false);
        }
예제 #17
0
        bool PromptCreatingNew(string path)
        {
            MessageBoxResult rslt = MessageBox.Show("Do you want to create new?", "There is no valid repository", MessageBoxButton.YesNo, MessageBoxImage.Error);

            if (rslt == MessageBoxResult.No)
            {
                return(false);
            }
            if (LibGitService.GetInstance().Size(path) > Properties.Settings.Default.recommendedCommits)
            {
                var result = MessageBox.Show("Opening repository with more than " + Properties.Settings.Default.recommendedCommits + " commits is not recommended due to slow redrawing. Do you want to open the repository anyways?", "", MessageBoxButton.YesNo, MessageBoxImage.Warning);
                if (result == MessageBoxResult.No)
                {
                    return(false);
                }
            }
            LibGitService.GetInstance().OpenNewRepository(path);
            return(Open(path));
        }
예제 #18
0
        public RepositoryValidation Create(string path)
        {
            var v = LibGitService.GetInstance().IsValidRepository(path);

            if (v == RepositoryValidation.Invalid)
            {
                if (LibGitService.GetInstance().Size(path) > 10000)
                {
                    var result = MessageBox.Show("Opening repository with more than 10000 commits is not recommended due to slow redrawing. Do you want to open the repository anyways?", "", MessageBoxButton.YesNo, MessageBoxImage.Warning);
                    if (result == MessageBoxResult.No)
                    {
                        return(RepositoryValidation.Valid);
                    }
                }
                LibGitService.GetInstance().OpenNewRepository(path);
                Open(path);
            }
            return(v);
        }
예제 #19
0
        Program()
        {
            ActionPanelModel    localAM       = new ActionPanelModel();
            MainWindowViewModel mwvm          = InitializeMainWindow();
            ActionPanelModel    remoteLeftAM  = MainWindowModel.RemoteLeftPanelModel;
            ActionPanelModel    remoteRightAM = MainWindowModel.RemoteRightPanelModel;

            CreateManagers(localAM, remoteLeftAM, remoteRightAM);
            InitializeEventHandlers();
            InitializeState();
            LibGitService.GetInstance().RepositoryChanged += CheckConflicts;
            LibGitService.GetInstance().RepositoryChanged += () => Show(null);
            LibGitService.GetInstance().RepositoryChanged += () => ActionsManager.OnWorkTreeChanged(LibGitService.GetInstance().HasChanges);
            StashMenuViewModel wm = new StashMenuViewModel(StashingManager.StashMenu);

            mwvm.StashMenu              = wm;
            RepositoryManager.Opened   += m => MainWindowModel.RepoPath = m.RepositoryPath;
            MainWindowModel.RecentRepos = RepositoryManager.RecentRepos;
            RepositoryManager.Closed   += m => { MainWindowModel.RepoPath = ""; MainWindowModel.RecentRepos = RepositoryManager.RecentRepos; RemoteManager.Reset(); };
            RepositoryManager.RecentRepositoryChanged += () => MainWindowModel.RecentRepos = RepositoryManager.RecentRepos;
            UserManager.UsersChanged += () => MainWindowModel.OnUsersChanged();
        }
예제 #20
0
 public void Branch(GraphItemModel i, string name)
 {
     LibGitService.Branch(i, name);
 }
예제 #21
0
 public EditorTabModel()
 {
     Refresh();
     LibGitService.GetInstance().RepositoryChanged += Refresh;
 }
예제 #22
0
 public void Commit(BranchLabelModel l, string message, IEnumerable <string> stagedFiles, IEnumerable <string> unstagedFiles)
 {
     LibGitService.GetInstance().Add(stagedFiles, unstagedFiles);
     LibGitService.Commit(l, message);
 }
예제 #23
0
 void SubscribeActionsManager()
 {
     ActionsManager.Commit   += EditCommit;
     ActionsManager.Checkout += CheckoutMarked;
     ActionsManager.Stash    += () => LibGitService.GetInstance().Stash();
 }
예제 #24
0
 private void AbortMerge()
 {
     LibGitService.GetInstance().AbortMerge();
 }
예제 #25
0
 public void Checkout(GraphItemModel m)
 {
     Program.GetInstance().StashingManager.ImplicitPush(m);
     LibGitService.Checkout(m);
     Graph.HighlightAsCheckouted(m);
 }
예제 #26
0
 private Graph()
 {
     LibGitService.GetInstance().RepositoryChangedPreview += () => DeployGraph();
 }
예제 #27
0
 public static ChangesInfo Modified(string path)
 {
     return(new ModifiedInfo(LibGitService.GetInstance().Diff(path)));
 }
예제 #28
0
 void Refresh()
 {
     RepositoryStatus  = LibGitService.GetInstance().Status;
     RepositoryChanges = LibGitService.GetInstance().CurrentChanges;
     RepositoryStatusChanged?.Invoke();
 }
예제 #29
0
 public static ChangesInfo Modified(string path, Commit c, Commit parent)
 {
     return(new ModifiedInfo(LibGitService.GetInstance().Diff(path, c, parent)));
 }
예제 #30
0
 public void FreeEvents()
 {
     LibGitService.GetInstance().RepositoryChanged -= Refresh;
 }