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(); } }
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; }
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; }
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; }
public static LibGitService GetInstance() { if (_instance == null) { _instance = new LibGitService(); } return(_instance); }
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; }
void SetupRepository() { CurrentRepository = LibGitService.GetInstance().Repository; CurrentRepositoryDirectory = FindRepositoryLogPathIfExists(); if (CurrentRepositoryDirectory == null) { CurrentRepositoryDirectory = CreateRepositoryLog(); } }
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(); }
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); } }
public void Rebase(BranchLabelModel rebasing, BranchLabelModel rebased) { GraphItemModel checkouted = Graph.Checkouted; Checkout(rebasing); bool succes = LibGitService.Merge(rebased); if (succes) { Checkout(rebased); } }
public void Merge(BranchLabelModel merging, BranchLabelModel merged) { GraphItemModel checkouted = Graph.Checkouted; Checkout(merging); bool succes = LibGitService.Merge(merged); if (succes) { Checkout(checkouted); } }
public void CheckConflicts() { _conflict = LibGitService.GetInstance().IsInConflictState; if (_conflict) { ActionsManager.TurnConflictState(); TabManager.TurnConflictState(); } else { ActionsManager.TurnNoConflictState(); TabManager.TurnNoConflictState(); } }
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); }
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); } } }
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); }
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); }
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)); }
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); }
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(); }
public void Branch(GraphItemModel i, string name) { LibGitService.Branch(i, name); }
public EditorTabModel() { Refresh(); LibGitService.GetInstance().RepositoryChanged += Refresh; }
public void Commit(BranchLabelModel l, string message, IEnumerable <string> stagedFiles, IEnumerable <string> unstagedFiles) { LibGitService.GetInstance().Add(stagedFiles, unstagedFiles); LibGitService.Commit(l, message); }
void SubscribeActionsManager() { ActionsManager.Commit += EditCommit; ActionsManager.Checkout += CheckoutMarked; ActionsManager.Stash += () => LibGitService.GetInstance().Stash(); }
private void AbortMerge() { LibGitService.GetInstance().AbortMerge(); }
public void Checkout(GraphItemModel m) { Program.GetInstance().StashingManager.ImplicitPush(m); LibGitService.Checkout(m); Graph.HighlightAsCheckouted(m); }
private Graph() { LibGitService.GetInstance().RepositoryChangedPreview += () => DeployGraph(); }
public static ChangesInfo Modified(string path) { return(new ModifiedInfo(LibGitService.GetInstance().Diff(path))); }
void Refresh() { RepositoryStatus = LibGitService.GetInstance().Status; RepositoryChanges = LibGitService.GetInstance().CurrentChanges; RepositoryStatusChanged?.Invoke(); }
public static ChangesInfo Modified(string path, Commit c, Commit parent) { return(new ModifiedInfo(LibGitService.GetInstance().Diff(path, c, parent))); }
public void FreeEvents() { LibGitService.GetInstance().RepositoryChanged -= Refresh; }