Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions src/Models/RepositoryUIStates.cs
Original file line number Diff line number Diff line change
Expand Up @@ -117,12 +117,30 @@ public bool PreferRebaseInsteadOfMerge
set;
} = true;

public DealWithLocalChanges? DealWithLocalChangesOnPull
{
get;
set;
} = null;

public bool CheckSubmodulesOnPush
{
get;
set;
} = true;

public bool SetTrackingOnPush
{
get;
set;
} = false;

public bool NoVerifyOnPush
{
get;
set;
} = false;

public bool PushAllTags
{
get;
Expand Down
1 change: 1 addition & 0 deletions src/Resources/Icons.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@
<StreamGeometry x:Key="Icons.Rename">M853 256h-43v512h43c47 0 85-38 85-85v-341c0-47-38-85-85-85zM725 768V171h128V85h-341v85H640v85H171c-47 0-85 38-85 85v341c0 47 38 85 85 85h469V853h-128v85h341v-85H725v-86zm-469-171v-171h384v171H256z</StreamGeometry>
<StreamGeometry x:Key="Icons.Repositories">M960 146v91C960 318 759 384 512 384S64 318 64 238V146C64 66 265 0 512 0s448 66 448 146zM960 352v206C960 638 759 704 512 704S64 638 64 558V352c96 66 272 97 448 97S864 418 960 352zm0 320v206C960 958 759 1024 512 1024S64 958 64 878V672c96 66 272 97 448 97S864 738 960 672z</StreamGeometry>
<StreamGeometry x:Key="Icons.Reset">M883 567l-128-128c-17-17-43-17-60 0l-128 128c-17 17-17 43 0 60 17 17 43 17 60 0l55-55V683c0 21-21 43-43 43H418c-13-38-43-64-77-77V375c51-17 85-64 85-119 0-73-60-128-128-128-73 0-128 55-128 128 0 55 34 102 85 119v269c-51 17-85 64-85 119 0 73 55 128 128 128 55 0 102-34 119-85H640c73 0 128-55 128-128v-111l55 55c9 9 17 13 30 13 13 0 21-4 30-13 17-13 17-43 0-55zM299 213c26 0 43 17 43 43 0 21-21 43-43 43-26 0-43-21-43-43 0-26 17-43 43-43zm0 597c-26 0-43-21-43-43 0-26 17-43 43-43s43 17 43 43c0 21-17 43-43 43zM725 384c-73 0-128-60-128-128 0-73 55-128 128-128s128 55 128 128c0 68-55 128-128 128zm0-171c-26 0-43 17-43 43s17 43 43 43 43-17 43-43-17-43-43-43z</StreamGeometry>
<StreamGeometry x:Key="Icons.ResetDefaults">M512 112A400 400 0 1 1 112 512H192A320 320 0 1 0 512 192V272L352 152L512 32Z</StreamGeometry>
<StreamGeometry x:Key="Icons.Save">M293 122v244h439V146l171 175V829a73 73 0 01-73 73h-98V536H293v366H195a73 73 0 01-73-73V195a73 73 0 0173-73h98zm366 512v268H366V634h293zm-49 49h-195v73h195v-73zm49-561v171H366V122h293z</StreamGeometry>
<StreamGeometry x:Key="Icons.Scan">M0 551V472c0-11 9-19 19-19h984c11 0 19 9 19 19v79c0 11-9 19-19 19H19c-11 0-19-9-19-19zM114 154v240c0 11-9 19-19 19H19C9 413 0 404 0 394V79C0 35 35 0 79 0h315c11 0 19 9 19 19v75c0 11-9 19-19 19H154c-21 0-39 18-39 39zm795 0c0-22-17-39-39-39h-240c-11 0-19-9-19-19V19c0-11 9-19 19-19h315c43 0 79 35 79 79v315c0 11-9 19-19 19h-75c-11 0-19-9-19-19l-1-240zm0 716v-240c0-11 9-19 19-19h75c11 0 19 9 19 19v315c0 43-35 79-79 79h-315c-11 0-19-9-19-19v-75c0-11 9-19 19-19H870c21-1 39-18 39-40zm-795 0c0 21 18 39 39 39h240c11 0 19 9 19 19v75c0 11-9 19-19 19H79C35 1023 0 988 0 945v-315c0-11 9-19 19-19h75c11 0 19 9 19 19V870z</StreamGeometry>
<StreamGeometry x:Key="Icons.ScrollToTop">M155 143h715v81H155V143zm358 94 358 369H662l1 278H363V605H155l358-369z</StreamGeometry>
Expand Down
3 changes: 3 additions & 0 deletions src/Resources/Locales/en_US.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -662,6 +662,8 @@
<x:String x:Key="Text.Period.MonthsAgo" xml:space="preserve">{0} months ago</x:String>
<x:String x:Key="Text.Period.YearsAgo" xml:space="preserve">{0} years ago</x:String>
<x:String x:Key="Text.Period.Yesterday" xml:space="preserve">Yesterday</x:String>
<x:String x:Key="Text.Popup.ResetDefaults" xml:space="preserve">Reset defaults</x:String>
<x:String x:Key="Text.Popup.SaveAsDefault" xml:space="preserve">Save as default</x:String>
<x:String x:Key="Text.Preferences" xml:space="preserve">Preferences</x:String>
<x:String x:Key="Text.Preferences.AI" xml:space="preserve">AI</x:String>
<x:String x:Key="Text.Preferences.AI.AdditionalPrompt" xml:space="preserve">Additional Prompt (Use `-` to list your requirements)</x:String>
Expand Down Expand Up @@ -850,6 +852,7 @@
<x:String x:Key="Text.Repository.ShowFirstParentOnly" xml:space="preserve">First-parent only</x:String>
<x:String x:Key="Text.Repository.ShowFlags" xml:space="preserve">SHOW FLAGS</x:String>
<x:String x:Key="Text.Repository.ShowLostCommits" xml:space="preserve">Show lost commits</x:String>
<x:String x:Key="Text.Repository.ShowOptions" xml:space="preserve">Show options...</x:String>
<x:String x:Key="Text.Repository.ShowSubmodulesAsTree" xml:space="preserve">Show Submodules as Tree</x:String>
<x:String x:Key="Text.Repository.ShowTagsAsTree" xml:space="preserve">Show Tags as Tree</x:String>
<x:String x:Key="Text.Repository.Skip" xml:space="preserve">SKIP</x:String>
Expand Down
57 changes: 43 additions & 14 deletions src/ViewModels/Fetch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,7 @@ public bool IsFetchAllRemoteVisible
public bool FetchAllRemotes
{
get => _fetchAllRemotes;
set
{
if (SetProperty(ref _fetchAllRemotes, value) && IsFetchAllRemoteVisible)
_repo.UIStates.FetchAllRemotes = value;
}
set => SetProperty(ref _fetchAllRemotes, value);
}

public Models.Remote SelectedRemote
Expand All @@ -34,21 +30,28 @@ public Models.Remote SelectedRemote

public bool NoTags
{
get => _repo.UIStates.FetchWithoutTags;
set => _repo.UIStates.FetchWithoutTags = value;
get => _noTags;
set => SetProperty(ref _noTags, value);
}

public bool Force
{
get => _repo.UIStates.EnableForceOnFetch;
set => _repo.UIStates.EnableForceOnFetch = value;
get => _force;
set => SetProperty(ref _force, value);
}

public override bool HasDefaultOptions
{
get => true;
}

public Fetch(Repository repo, Models.Remote preferredRemote = null)
{
_repo = repo;
IsFetchAllRemoteVisible = repo.Remotes.Count > 1 && preferredRemote == null;
_fetchAllRemotes = IsFetchAllRemoteVisible && _repo.UIStates.FetchAllRemotes;
_noTags = _repo.UIStates.FetchWithoutTags;
_force = _repo.UIStates.EnableForceOnFetch;
CanTerminate = true;

if (preferredRemote != null)
Expand All @@ -66,6 +69,29 @@ public Fetch(Repository repo, Models.Remote preferredRemote = null)
}
}

public override void SaveOptionsAsDefault()
{
if (IsFetchAllRemoteVisible)
_repo.UIStates.FetchAllRemotes = _fetchAllRemotes;

_repo.UIStates.FetchWithoutTags = _noTags;
_repo.UIStates.EnableForceOnFetch = _force;
_repo.UIStates.Save();
}

public override void ResetDefaultOptions()
{
var defaults = new Models.RepositoryUIStates();
_repo.UIStates.FetchAllRemotes = defaults.FetchAllRemotes;
_repo.UIStates.FetchWithoutTags = defaults.FetchWithoutTags;
_repo.UIStates.EnableForceOnFetch = defaults.EnableForceOnFetch;
_repo.UIStates.Save();

FetchAllRemotes = IsFetchAllRemoteVisible && defaults.FetchAllRemotes;
NoTags = defaults.FetchWithoutTags;
Force = defaults.EnableForceOnFetch;
}

public override async Task<bool> Sure()
{
using var lockWatcher = _repo.LockWatcher();
Expand All @@ -74,19 +100,20 @@ public override async Task<bool> Sure()
_repo.Histories.SelectedCommits.Count == 1 &&
_repo.Histories.SelectedCommits[0].IsCurrentHead;

var notags = _repo.UIStates.FetchWithoutTags;
var force = _repo.UIStates.EnableForceOnFetch;
var notags = _noTags;
var force = _force;
var log = _repo.CreateLog("Fetch");
Use(log);

_cancellation = new CancellationTokenSource();
var token = _cancellation.Token;

var succ = true;
if (FetchAllRemotes)
{
foreach (var remote in _repo.Remotes)
{
await new Commands.Fetch(_repo.FullPath, remote, notags, force)
succ &= await new Commands.Fetch(_repo.FullPath, remote, notags, force)
.WithCancellation(token)
.Use(log)
.ExecAsync();
Expand All @@ -97,7 +124,7 @@ public override async Task<bool> Sure()
}
else
{
await new Commands.Fetch(_repo.FullPath, SelectedRemote, notags, force)
succ = await new Commands.Fetch(_repo.FullPath, SelectedRemote, notags, force)
.WithCancellation(token)
.Use(log)
.ExecAsync();
Expand All @@ -119,7 +146,7 @@ public override async Task<bool> Sure()
_repo.MarkFetched();

_cancellation = null;
return true;
return succ;
}

public override void Terminate()
Expand All @@ -130,6 +157,8 @@ public override void Terminate()

private readonly Repository _repo = null;
private bool _fetchAllRemotes = false;
private bool _noTags = false;
private bool _force = false;
private CancellationTokenSource _cancellation = null;
}
}
13 changes: 13 additions & 0 deletions src/ViewModels/Popup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,24 @@ public void Cleanup()
_log?.Unsubscribe(this);
}

public virtual bool HasDefaultOptions
{
get => false;
}

public virtual bool CanStartDirectly()
{
return true;
}

public virtual void SaveOptionsAsDefault()
{
}

public virtual void ResetDefaultOptions()
{
}

public virtual Task<bool> Sure()
{
return null;
Expand Down
45 changes: 38 additions & 7 deletions src/ViewModels/Pull.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,19 @@ public bool HasLocalChanges

public Models.DealWithLocalChanges DealWithLocalChanges
{
get;
set;
get => _dealWithLocalChanges;
set => SetProperty(ref _dealWithLocalChanges, value);
}

public bool UseRebase
{
get => _repo.UIStates.PreferRebaseInsteadOfMerge;
set => _repo.UIStates.PreferRebaseInsteadOfMerge = value;
get => _useRebase;
set => SetProperty(ref _useRebase, value);
}

public override bool HasDefaultOptions
{
get => true;
}

public Pull(Repository repo, Models.Branch specifiedRemoteBranch)
Expand All @@ -63,9 +68,8 @@ public Pull(Repository repo, Models.Branch specifiedRemoteBranch)
Current = repo.CurrentBranch;
CanTerminate = true;

DealWithLocalChanges = Preferences.Instance.UseStashAndReapplyByDefault ?
Models.DealWithLocalChanges.StashAndReapply :
Models.DealWithLocalChanges.DoNothing;
_dealWithLocalChanges = repo.UIStates.DealWithLocalChangesOnPull ?? GetPreferredDealWithLocalChanges();
_useRebase = repo.UIStates.PreferRebaseInsteadOfMerge;

if (specifiedRemoteBranch != null)
{
Expand Down Expand Up @@ -112,6 +116,24 @@ public Pull(Repository repo, Models.Branch specifiedRemoteBranch)
}
}

public override void SaveOptionsAsDefault()
{
_repo.UIStates.DealWithLocalChangesOnPull = _dealWithLocalChanges;
_repo.UIStates.PreferRebaseInsteadOfMerge = _useRebase;
_repo.UIStates.Save();
}

public override void ResetDefaultOptions()
{
var defaults = new Models.RepositoryUIStates();
_repo.UIStates.DealWithLocalChangesOnPull = defaults.DealWithLocalChangesOnPull;
_repo.UIStates.PreferRebaseInsteadOfMerge = defaults.PreferRebaseInsteadOfMerge;
_repo.UIStates.Save();

DealWithLocalChanges = GetPreferredDealWithLocalChanges();
UseRebase = defaults.PreferRebaseInsteadOfMerge;
}

public override async Task<bool> Sure()
{
using var lockWatcher = _repo.LockWatcher();
Expand Down Expand Up @@ -189,6 +211,13 @@ public override void Terminate()
var _ = _cancellation?.CancelAsync();
}

private static Models.DealWithLocalChanges GetPreferredDealWithLocalChanges()
{
return Preferences.Instance.UseStashAndReapplyByDefault ?
Models.DealWithLocalChanges.StashAndReapply :
Models.DealWithLocalChanges.DoNothing;
}

private void PostRemoteSelected()
{
var remoteName = _selectedRemote.Name;
Expand All @@ -214,6 +243,8 @@ private void PostRemoteSelected()
private Models.Remote _selectedRemote = null;
private List<Models.Branch> _remoteBranches = null;
private Models.Branch _selectedBranch = null;
private Models.DealWithLocalChanges _dealWithLocalChanges = Models.DealWithLocalChanges.DoNothing;
private bool _useRebase = true;
private CancellationTokenSource _cancellation = null;
}
}
50 changes: 43 additions & 7 deletions src/ViewModels/Push.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,14 +87,14 @@ public bool IsCheckSubmodulesVisible

public bool CheckSubmodules
{
get;
set;
} = true;
get => _checkSubmodules;
set => SetProperty(ref _checkSubmodules, value);
}

public bool PushAllTags
{
get => _repo.UIStates.PushAllTags;
set => _repo.UIStates.PushAllTags = value;
get => _pushAllTags;
set => SetProperty(ref _pushAllTags, value);
}

public bool ForcePush
Expand All @@ -105,13 +105,22 @@ public bool ForcePush

public bool NoVerify
{
get;
set;
get => _noVerify;
set => SetProperty(ref _noVerify, value);
}

public override bool HasDefaultOptions
{
get => true;
}

public Push(Repository repo, Models.Branch localBranch)
{
_repo = repo;
_tracking = repo.UIStates.SetTrackingOnPush;
_checkSubmodules = repo.UIStates.CheckSubmodulesOnPush;
_pushAllTags = repo.UIStates.PushAllTags;
_noVerify = repo.UIStates.NoVerifyOnPush;
CanTerminate = true;

// Gather all local branches and find current branch.
Expand Down Expand Up @@ -162,6 +171,30 @@ public void PushToNewBranch(string name)
SelectedRemoteBranch = fake;
}

public override void SaveOptionsAsDefault()
{
_repo.UIStates.SetTrackingOnPush = _tracking;
_repo.UIStates.CheckSubmodulesOnPush = _checkSubmodules;
_repo.UIStates.PushAllTags = _pushAllTags;
_repo.UIStates.NoVerifyOnPush = _noVerify;
_repo.UIStates.Save();
}

public override void ResetDefaultOptions()
{
var defaults = new Models.RepositoryUIStates();
_repo.UIStates.SetTrackingOnPush = defaults.SetTrackingOnPush;
_repo.UIStates.CheckSubmodulesOnPush = defaults.CheckSubmodulesOnPush;
_repo.UIStates.PushAllTags = defaults.PushAllTags;
_repo.UIStates.NoVerifyOnPush = defaults.NoVerifyOnPush;
_repo.UIStates.Save();

Tracking = defaults.SetTrackingOnPush;
CheckSubmodules = defaults.CheckSubmodulesOnPush;
PushAllTags = defaults.PushAllTags;
NoVerify = defaults.NoVerifyOnPush;
}

public override bool CanStartDirectly()
{
return !string.IsNullOrEmpty(_selectedRemoteBranch?.Head);
Expand Down Expand Up @@ -357,6 +390,9 @@ private bool IsPreferredPushRemote(Models.Remote remote)
private Models.Branch _selectedRemoteBranch = null;
private bool _isSetTrackOptionVisible = false;
private bool _tracking = false;
private bool _checkSubmodules = true;
private bool _pushAllTags = false;
private bool _noVerify = false;
private CancellationTokenSource _cancellation = null;
}
}
Loading