public void Popout(RepositoryItem selectionDetails) { if (selectionDetails != null) { new GitShellVisible(selectionDetails.Path).InstantiateVisibleShell(); } }
public void ChangeRepository(RepositoryItem selectionDetails) { if (selectionDetails != null) { GitListDataContext.ConsoleControl.ClearOutput(); GitListDataContext.ConsoleControl.WriteInput(string.Format("cd \"{0}\"", selectionDetails.Path.ToLower()), Color.FromRgb(1, 100, 3), false); } }
public List<string> CommitLog(RepositoryItem repository) { var repo = new LibGit2Sharp.Repository(repository.Path); var commitLog = new List<string>(); repo.Commits.ToList().ForEach(commit => { commitLog.Add(string.Format("{0} - {1} : {2}", commit.Author.When.LocalDateTime, commit.Author.Name, commit.Message)); }); return commitLog; }
public void ChangeRepositoryBranch(RepositoryItem item) { if (item != null && !string.IsNullOrEmpty(item.CurrentBranch)) { SetRootRefreshInProgress(item.Parent); new Thread(() => { ChangeBranch(item); Thread.Sleep(TimeSpan.FromSeconds(5)); DispatchInvoker.InvokeBackground(() => { RefreshRepositories(item.Parent, false); }); }).Start(); } }
public List<string> Branches(RepositoryItem repository) { var repo = new LibGit2Sharp.Repository(repository.Path); return repo.Branches.Select(x => x.Name).Distinct().ToList(); }
public int BehindBy(RepositoryItem repository) { var repo = new LibGit2Sharp.Repository(repository.Path); var behindBy = repo.Head.TrackingDetails.BehindBy ?? 0; return behindBy; }
public int Aheadby(RepositoryItem repository) { var repo = new LibGit2Sharp.Repository(repository.Path); var aheadBy = repo.Head.TrackingDetails.AheadBy ?? 0; return aheadBy; }
private LibGit2Sharp.Repository CurrentBranch(RepositoryItem repository) { return new LibGit2Sharp.Repository(repository.Path); }
public string GetCurrentBranchName(RepositoryItem item) { var branchName = new GitManager().CurrentBranchName(item); if (branchName == "(no branch)") { branchName = "DETACHED HEAD"; } return branchName; }
//public void Reset(RepositoryItem repository) //{ // try // { // var repo = new LibGit2Sharp.Repository(repository.Path); // repo.RemoveUntrackedFiles(); // repo.Reset(ResetMode.Hard); // } // catch(Exception e) // { // } //} public void FetchAndReset(RepositoryItem repository) { var repo = new LibGit2Sharp.Repository(repository.Path); var currentBranch = CurrentBranch(repository); //foreach (Remote remote in repo.Network.Remotes) //{ // //FetchOptions options = new FetchOptions(); // //options.CredentialsProvider = new CredentialsHandler( // // (url, usernameFromUrl, types) => // // new UsernamePasswordCredentials() // // { // // Username = "******", // // Password = "******" // // }); // //repo.Network.Pull(new Signature(Guid.NewGuid().ToString(), Guid.NewGuid().ToString(), DateTime.Now), new PullOptions()); //} List<string> Commands = new List<string>() { "git fetch --all --prune", //below line works ok if you are on master, not if you are on a different branch. //string.Format("git reset --hard {0}", string.Format("{0}/{1}",currentBranch.Head.Remote.Name, currentBranch.Head.Name)), //"git reset --hard", //string.Format("git reset --hard {0}", currentBranch.Head.TrackedBranch.UpstreamBranchCanonicalName), "git reset --hard HEAD^", "git clean -d -f -f", "git pull" }; RunGitCommands(repository.Path, Commands); }
private ObservableCollection<string> GetBranchList(RepositoryItem item) { var list = new ObservableCollection<string>(); new GitManager().Branches(item).ForEach(list.Add); if (list.Count == 0) { list.Add("master"); } list.Add("DETACHED HEAD"); return list; }
private void ChangeBranch(RepositoryItem item) { item.Message = null; new Thread(() => { try { if (item.CurrentBranch == "DETACHED HEAD") { item.Message = "You cannot checkout branch 'DETACHED HEAD'"; } else { new GitManager().ChangeBranch(item, item.CurrentBranch); } } catch (Exception e) { DispatchInvoker.InvokeBackground(() => { item.Message = e.Message; item.InProgress = false; }); } DispatchInvoker.InvokeBackground(() => { item.CurrentBranch = GetCurrentBranchName(item); item.InProgress = false; }); }).Start(); }
public List<string> Changes(RepositoryItem repository) { var repo = new LibGit2Sharp.Repository(repository.Path); return repo.RetrieveStatus().Where(x => x.State != FileStatus.Ignored).Select(x => x.FilePath).ToList(); }
public bool IsValidRepository(RepositoryItem repository) { return LibGit2Sharp.Repository.IsValid(repository.Path); }
public string CurrentBranchName(RepositoryItem repository) { return CurrentBranch(repository).Head.Name; }
//public void Reset(RepositoryItem item) //{ // new GitManager().Reset(item); //} public void Fetch(RepositoryItem item) { new GitManager().FetchAndReset(item); DispatchInvoker.InvokeBackground(() => { item.InProgress = false; }); }
public void ChangeBranch(RepositoryItem repository, string BranchName) { var repo = new LibGit2Sharp.Repository(repository.Path); var branches = repo.Branches.Where(b => b.Name == BranchName).ToList(); if (branches.Any()) { var localBranch = branches.FirstOrDefault(x => !x.IsRemote); if (localBranch != null) { repo.Checkout(localBranch, new CheckoutOptions(), new Signature(Guid.NewGuid().ToString(), Guid.NewGuid().ToString(), DateTime.Now)); } else { throw new Exception("You must checkout manually the first time"); //COMMENTED THIS OUT AS IT CREATES DUPLICATE REMOTE BRANCHES, For instance R15_Release will duplicate as origin/R15_Release. //Current work around is to get them to check out the branch manually the first time around. //var remoteBranch = branches.FirstOrDefault(x => x.IsRemote); //if (remoteBranch != null) //{ // var newLocalBranch = repo.CreateBranch(BranchName, remoteBranch.Tip); // newLocalBranch = repo.Branches.Update(newLocalBranch, // b => // { // b.TrackedBranch = remoteBranch.CanonicalName; // }); // repo.Checkout(newLocalBranch, new CheckoutOptions(), new Signature(Guid.NewGuid().ToString(), Guid.NewGuid().ToString(), DateTime.Now)); //} } } }