mirror of
https://github.com/sourcegit-scm/sourcegit.git
synced 2025-01-11 23:57:21 -08:00
feature: auto-change filter branches after checkout (#855)
This commit is contained in:
parent
2a55ba6d07
commit
127315528a
2 changed files with 18 additions and 4 deletions
|
@ -65,8 +65,14 @@ namespace SourceGit.ViewModels
|
|||
{
|
||||
var b = _repo.Branches.Find(x => x.IsLocal && x.Name == Branch);
|
||||
if (b != null && _repo.HistoriesFilterMode == Models.FilterMode.Included)
|
||||
{
|
||||
_repo.Settings.HistoriesFilters.Clear();
|
||||
_repo.Settings.UpdateHistoriesFilter(b.FullName, Models.FilterType.LocalBranch, Models.FilterMode.Included);
|
||||
|
||||
if (!string.IsNullOrEmpty(b.Upstream))
|
||||
_repo.Settings.UpdateHistoriesFilter(b.Upstream, Models.FilterType.LocalBranch, Models.FilterMode.Included);
|
||||
}
|
||||
|
||||
_repo.MarkBranchesDirtyManually();
|
||||
_repo.SetWatcherEnabled(true);
|
||||
});
|
||||
|
|
|
@ -83,6 +83,7 @@ namespace SourceGit.ViewModels
|
|||
_repo.SetWatcherEnabled(false);
|
||||
return Task.Run(() =>
|
||||
{
|
||||
var succ = false;
|
||||
if (CheckoutAfterCreated)
|
||||
{
|
||||
var changes = new Commands.CountLocalChangesWithoutUntracked(_repo.FullPath).Result();
|
||||
|
@ -92,7 +93,7 @@ namespace SourceGit.ViewModels
|
|||
if (PreAction == Models.DealWithLocalChanges.StashAndReaply)
|
||||
{
|
||||
SetProgressDescription("Stash local changes");
|
||||
var succ = new Commands.Stash(_repo.FullPath).Push("CREATE_BRANCH_AUTO_STASH");
|
||||
succ = new Commands.Stash(_repo.FullPath).Push("CREATE_BRANCH_AUTO_STASH");
|
||||
if (!succ)
|
||||
{
|
||||
CallUIThread(() => _repo.SetWatcherEnabled(true));
|
||||
|
@ -109,7 +110,7 @@ namespace SourceGit.ViewModels
|
|||
}
|
||||
|
||||
SetProgressDescription($"Create new branch '{_name}'");
|
||||
new Commands.Checkout(_repo.FullPath).Branch(_name, _baseOnRevision, SetProgressDescription);
|
||||
succ = new Commands.Checkout(_repo.FullPath).Branch(_name, _baseOnRevision, SetProgressDescription);
|
||||
|
||||
if (needPopStash)
|
||||
{
|
||||
|
@ -120,17 +121,24 @@ namespace SourceGit.ViewModels
|
|||
else
|
||||
{
|
||||
SetProgressDescription($"Create new branch '{_name}'");
|
||||
Commands.Branch.Create(_repo.FullPath, _name, _baseOnRevision);
|
||||
succ = Commands.Branch.Create(_repo.FullPath, _name, _baseOnRevision);
|
||||
}
|
||||
|
||||
CallUIThread(() =>
|
||||
{
|
||||
if (CheckoutAfterCreated && _repo.HistoriesFilterMode == Models.FilterMode.Included)
|
||||
if (succ && CheckoutAfterCreated && _repo.HistoriesFilterMode == Models.FilterMode.Included)
|
||||
{
|
||||
_repo.Settings.HistoriesFilters.Clear();
|
||||
_repo.Settings.UpdateHistoriesFilter($"refs/heads/{_name}", Models.FilterType.LocalBranch, Models.FilterMode.Included);
|
||||
|
||||
if (BasedOn is Models.Branch b && !b.IsLocal)
|
||||
_repo.Settings.UpdateHistoriesFilter(b.FullName, Models.FilterType.LocalBranch, Models.FilterMode.Included);
|
||||
}
|
||||
|
||||
_repo.MarkBranchesDirtyManually();
|
||||
_repo.SetWatcherEnabled(true);
|
||||
});
|
||||
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue