mirror of
https://github.com/sourcegit-scm/sourcegit
synced 2025-05-21 12:15:00 +00:00
refactor: use view locator instead of creating views manually in viewmodels (#1213)
Signed-off-by: leo <longshuang@msn.cn>
This commit is contained in:
parent
413669741d
commit
5fd074a9b6
60 changed files with 52 additions and 140 deletions
|
@ -47,7 +47,6 @@ namespace SourceGit.ViewModels
|
||||||
public AddRemote(Repository repo)
|
public AddRemote(Repository repo)
|
||||||
{
|
{
|
||||||
_repo = repo;
|
_repo = repo;
|
||||||
View = new Views.AddRemote() { DataContext = this };
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ValidationResult ValidateRemoteName(string name, ValidationContext ctx)
|
public static ValidationResult ValidateRemoteName(string name, ValidationContext ctx)
|
||||||
|
|
|
@ -31,7 +31,6 @@ namespace SourceGit.ViewModels
|
||||||
public AddSubmodule(Repository repo)
|
public AddSubmodule(Repository repo)
|
||||||
{
|
{
|
||||||
_repo = repo;
|
_repo = repo;
|
||||||
View = new Views.AddSubmodule() { DataContext = this };
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ValidationResult ValidateURL(string url, ValidationContext ctx)
|
public static ValidationResult ValidateURL(string url, ValidationContext ctx)
|
||||||
|
|
|
@ -78,8 +78,6 @@ namespace SourceGit.ViewModels
|
||||||
SelectedTrackingBranch = RemoteBranches[0];
|
SelectedTrackingBranch = RemoteBranches[0];
|
||||||
else
|
else
|
||||||
SelectedTrackingBranch = string.Empty;
|
SelectedTrackingBranch = string.Empty;
|
||||||
|
|
||||||
View = new Views.AddWorktree() { DataContext = this };
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ValidationResult ValidateWorktreePath(string path, ValidationContext ctx)
|
public static ValidationResult ValidateWorktreePath(string path, ValidationContext ctx)
|
||||||
|
|
|
@ -31,7 +31,6 @@ namespace SourceGit.ViewModels
|
||||||
_repo = repo;
|
_repo = repo;
|
||||||
|
|
||||||
SelectedWhiteSpaceMode = Models.ApplyWhiteSpaceMode.Supported[0];
|
SelectedWhiteSpaceMode = Models.ApplyWhiteSpaceMode.Supported[0];
|
||||||
View = new Views.Apply() { DataContext = this };
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ValidationResult ValidatePatchFile(string file, ValidationContext _)
|
public static ValidationResult ValidatePatchFile(string file, ValidationContext _)
|
||||||
|
|
|
@ -26,7 +26,6 @@ namespace SourceGit.ViewModels
|
||||||
{
|
{
|
||||||
_repo = repo;
|
_repo = repo;
|
||||||
Stash = stash;
|
Stash = stash;
|
||||||
View = new Views.ApplyStash() { DataContext = this };
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override Task<bool> Sure()
|
public override Task<bool> Sure()
|
||||||
|
|
|
@ -25,7 +25,6 @@ namespace SourceGit.ViewModels
|
||||||
_revision = branch.Head;
|
_revision = branch.Head;
|
||||||
_saveFile = $"archive-{Path.GetFileName(branch.Name)}.zip";
|
_saveFile = $"archive-{Path.GetFileName(branch.Name)}.zip";
|
||||||
BasedOn = branch;
|
BasedOn = branch;
|
||||||
View = new Views.Archive() { DataContext = this };
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Archive(Repository repo, Models.Commit commit)
|
public Archive(Repository repo, Models.Commit commit)
|
||||||
|
@ -34,7 +33,6 @@ namespace SourceGit.ViewModels
|
||||||
_revision = commit.SHA;
|
_revision = commit.SHA;
|
||||||
_saveFile = $"archive-{commit.SHA.Substring(0, 10)}.zip";
|
_saveFile = $"archive-{commit.SHA.Substring(0, 10)}.zip";
|
||||||
BasedOn = commit;
|
BasedOn = commit;
|
||||||
View = new Views.Archive() { DataContext = this };
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Archive(Repository repo, Models.Tag tag)
|
public Archive(Repository repo, Models.Tag tag)
|
||||||
|
@ -43,7 +41,6 @@ namespace SourceGit.ViewModels
|
||||||
_revision = tag.SHA;
|
_revision = tag.SHA;
|
||||||
_saveFile = $"archive-{Path.GetFileName(tag.Name)}.zip";
|
_saveFile = $"archive-{Path.GetFileName(tag.Name)}.zip";
|
||||||
BasedOn = tag;
|
BasedOn = tag;
|
||||||
View = new Views.Archive() { DataContext = this };
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override Task<bool> Sure()
|
public override Task<bool> Sure()
|
||||||
|
|
|
@ -20,7 +20,6 @@ namespace SourceGit.ViewModels
|
||||||
_repo = repo;
|
_repo = repo;
|
||||||
Branch = branch;
|
Branch = branch;
|
||||||
DiscardLocalChanges = false;
|
DiscardLocalChanges = false;
|
||||||
View = new Views.Checkout() { DataContext = this };
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override Task<bool> Sure()
|
public override Task<bool> Sure()
|
||||||
|
|
|
@ -20,7 +20,6 @@ namespace SourceGit.ViewModels
|
||||||
_repo = repo;
|
_repo = repo;
|
||||||
Commit = commit;
|
Commit = commit;
|
||||||
DiscardLocalChanges = false;
|
DiscardLocalChanges = false;
|
||||||
View = new Views.CheckoutCommit() { DataContext = this };
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override Task<bool> Sure()
|
public override Task<bool> Sure()
|
||||||
|
|
|
@ -50,7 +50,6 @@ namespace SourceGit.ViewModels
|
||||||
MainlineForMergeCommit = 0;
|
MainlineForMergeCommit = 0;
|
||||||
AppendSourceToMessage = true;
|
AppendSourceToMessage = true;
|
||||||
AutoCommit = true;
|
AutoCommit = true;
|
||||||
View = new Views.CherryPick() { DataContext = this };
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public CherryPick(Repository repo, Models.Commit merge, List<Models.Commit> parents)
|
public CherryPick(Repository repo, Models.Commit merge, List<Models.Commit> parents)
|
||||||
|
@ -62,7 +61,6 @@ namespace SourceGit.ViewModels
|
||||||
MainlineForMergeCommit = 0;
|
MainlineForMergeCommit = 0;
|
||||||
AppendSourceToMessage = true;
|
AppendSourceToMessage = true;
|
||||||
AutoCommit = true;
|
AutoCommit = true;
|
||||||
View = new Views.CherryPick() { DataContext = this };
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override Task<bool> Sure()
|
public override Task<bool> Sure()
|
||||||
|
|
|
@ -7,7 +7,6 @@ namespace SourceGit.ViewModels
|
||||||
public Cleanup(Repository repo)
|
public Cleanup(Repository repo)
|
||||||
{
|
{
|
||||||
_repo = repo;
|
_repo = repo;
|
||||||
View = new Views.Cleanup() { DataContext = this };
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override Task<bool> Sure()
|
public override Task<bool> Sure()
|
||||||
|
|
|
@ -7,7 +7,6 @@ namespace SourceGit.ViewModels
|
||||||
public ClearStashes(Repository repo)
|
public ClearStashes(Repository repo)
|
||||||
{
|
{
|
||||||
_repo = repo;
|
_repo = repo;
|
||||||
View = new Views.ClearStashes() { DataContext = this };
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override Task<bool> Sure()
|
public override Task<bool> Sure()
|
||||||
|
|
|
@ -68,8 +68,6 @@ namespace SourceGit.ViewModels
|
||||||
if (string.IsNullOrEmpty(ParentFolder))
|
if (string.IsNullOrEmpty(ParentFolder))
|
||||||
_parentFolder = Preferences.Instance.GitDefaultCloneDir;
|
_parentFolder = Preferences.Instance.GitDefaultCloneDir;
|
||||||
|
|
||||||
View = new Views.Clone() { DataContext = this };
|
|
||||||
|
|
||||||
Task.Run(async () =>
|
Task.Run(async () =>
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
|
|
@ -48,7 +48,6 @@ namespace SourceGit.ViewModels
|
||||||
|
|
||||||
BasedOn = branch;
|
BasedOn = branch;
|
||||||
DiscardLocalChanges = false;
|
DiscardLocalChanges = false;
|
||||||
View = new Views.CreateBranch() { DataContext = this };
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public CreateBranch(Repository repo, Models.Commit commit)
|
public CreateBranch(Repository repo, Models.Commit commit)
|
||||||
|
@ -58,7 +57,6 @@ namespace SourceGit.ViewModels
|
||||||
|
|
||||||
BasedOn = commit;
|
BasedOn = commit;
|
||||||
DiscardLocalChanges = false;
|
DiscardLocalChanges = false;
|
||||||
View = new Views.CreateBranch() { DataContext = this };
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public CreateBranch(Repository repo, Models.Tag tag)
|
public CreateBranch(Repository repo, Models.Tag tag)
|
||||||
|
@ -68,7 +66,6 @@ namespace SourceGit.ViewModels
|
||||||
|
|
||||||
BasedOn = tag;
|
BasedOn = tag;
|
||||||
DiscardLocalChanges = false;
|
DiscardLocalChanges = false;
|
||||||
View = new Views.CreateBranch() { DataContext = this };
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ValidationResult ValidateBranchName(string name, ValidationContext ctx)
|
public static ValidationResult ValidateBranchName(string name, ValidationContext ctx)
|
||||||
|
@ -97,7 +94,7 @@ namespace SourceGit.ViewModels
|
||||||
|
|
||||||
return Task.Run(() =>
|
return Task.Run(() =>
|
||||||
{
|
{
|
||||||
var succ = false;
|
bool succ;
|
||||||
if (CheckoutAfterCreated && !_repo.IsBare)
|
if (CheckoutAfterCreated && !_repo.IsBare)
|
||||||
{
|
{
|
||||||
var changes = new Commands.CountLocalChangesWithoutUntracked(_repo.FullPath).Result();
|
var changes = new Commands.CountLocalChangesWithoutUntracked(_repo.FullPath).Result();
|
||||||
|
|
|
@ -16,7 +16,6 @@ namespace SourceGit.ViewModels
|
||||||
public CreateGroup(RepositoryNode parent)
|
public CreateGroup(RepositoryNode parent)
|
||||||
{
|
{
|
||||||
_parent = parent;
|
_parent = parent;
|
||||||
View = new Views.CreateGroup() { DataContext = this };
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override Task<bool> Sure()
|
public override Task<bool> Sure()
|
||||||
|
|
|
@ -52,7 +52,6 @@ namespace SourceGit.ViewModels
|
||||||
|
|
||||||
BasedOn = branch;
|
BasedOn = branch;
|
||||||
SignTag = new Commands.Config(repo.FullPath).Get("tag.gpgsign").Equals("true", StringComparison.OrdinalIgnoreCase);
|
SignTag = new Commands.Config(repo.FullPath).Get("tag.gpgsign").Equals("true", StringComparison.OrdinalIgnoreCase);
|
||||||
View = new Views.CreateTag() { DataContext = this };
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public CreateTag(Repository repo, Models.Commit commit)
|
public CreateTag(Repository repo, Models.Commit commit)
|
||||||
|
@ -62,7 +61,6 @@ namespace SourceGit.ViewModels
|
||||||
|
|
||||||
BasedOn = commit;
|
BasedOn = commit;
|
||||||
SignTag = new Commands.Config(repo.FullPath).Get("tag.gpgsign").Equals("true", StringComparison.OrdinalIgnoreCase);
|
SignTag = new Commands.Config(repo.FullPath).Get("tag.gpgsign").Equals("true", StringComparison.OrdinalIgnoreCase);
|
||||||
View = new Views.CreateTag() { DataContext = this };
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ValidationResult ValidateTagName(string name, ValidationContext ctx)
|
public static ValidationResult ValidateTagName(string name, ValidationContext ctx)
|
||||||
|
|
|
@ -39,8 +39,6 @@ namespace SourceGit.ViewModels
|
||||||
if (TrackingRemoteBranch != null)
|
if (TrackingRemoteBranch != null)
|
||||||
DeleteTrackingRemoteTip = new Views.NameHighlightedTextBlock("DeleteBranch.WithTrackingRemote", TrackingRemoteBranch.FriendlyName);
|
DeleteTrackingRemoteTip = new Views.NameHighlightedTextBlock("DeleteBranch.WithTrackingRemote", TrackingRemoteBranch.FriendlyName);
|
||||||
}
|
}
|
||||||
|
|
||||||
View = new Views.DeleteBranch() { DataContext = this };
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override Task<bool> Sure()
|
public override Task<bool> Sure()
|
||||||
|
|
|
@ -15,7 +15,6 @@ namespace SourceGit.ViewModels
|
||||||
_repo = repo;
|
_repo = repo;
|
||||||
_isLocal = isLocal;
|
_isLocal = isLocal;
|
||||||
Targets = branches;
|
Targets = branches;
|
||||||
View = new Views.DeleteMultipleBranches() { DataContext = this };
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override Task<bool> Sure()
|
public override Task<bool> Sure()
|
||||||
|
|
|
@ -14,7 +14,6 @@ namespace SourceGit.ViewModels
|
||||||
{
|
{
|
||||||
_repo = repo;
|
_repo = repo;
|
||||||
Remote = remote;
|
Remote = remote;
|
||||||
View = new Views.DeleteRemote() { DataContext = this };
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override Task<bool> Sure()
|
public override Task<bool> Sure()
|
||||||
|
|
|
@ -6,23 +6,19 @@ namespace SourceGit.ViewModels
|
||||||
{
|
{
|
||||||
public RepositoryNode Node
|
public RepositoryNode Node
|
||||||
{
|
{
|
||||||
get => _node;
|
get;
|
||||||
set => SetProperty(ref _node, value);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public DeleteRepositoryNode(RepositoryNode node)
|
public DeleteRepositoryNode(RepositoryNode node)
|
||||||
{
|
{
|
||||||
_node = node;
|
Node = node;
|
||||||
View = new Views.DeleteRepositoryNode() { DataContext = this };
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override Task<bool> Sure()
|
public override Task<bool> Sure()
|
||||||
{
|
{
|
||||||
Preferences.Instance.RemoveNode(_node, true);
|
Preferences.Instance.RemoveNode(Node, true);
|
||||||
Welcome.Instance.Refresh();
|
Welcome.Instance.Refresh();
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private RepositoryNode _node = null;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,6 @@ namespace SourceGit.ViewModels
|
||||||
{
|
{
|
||||||
public class DeleteSubmodule : Popup
|
public class DeleteSubmodule : Popup
|
||||||
{
|
{
|
||||||
|
|
||||||
public string Submodule
|
public string Submodule
|
||||||
{
|
{
|
||||||
get;
|
get;
|
||||||
|
@ -15,7 +14,6 @@ namespace SourceGit.ViewModels
|
||||||
{
|
{
|
||||||
_repo = repo;
|
_repo = repo;
|
||||||
Submodule = submodule;
|
Submodule = submodule;
|
||||||
View = new Views.DeleteSubmodule() { DataContext = this };
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override Task<bool> Sure()
|
public override Task<bool> Sure()
|
||||||
|
|
|
@ -20,7 +20,6 @@ namespace SourceGit.ViewModels
|
||||||
{
|
{
|
||||||
_repo = repo;
|
_repo = repo;
|
||||||
Target = tag;
|
Target = tag;
|
||||||
View = new Views.DeleteTag() { DataContext = this };
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override Task<bool> Sure()
|
public override Task<bool> Sure()
|
||||||
|
|
|
@ -40,9 +40,7 @@ namespace SourceGit.ViewModels
|
||||||
public Discard(Repository repo)
|
public Discard(Repository repo)
|
||||||
{
|
{
|
||||||
_repo = repo;
|
_repo = repo;
|
||||||
|
|
||||||
Mode = new DiscardAllMode();
|
Mode = new DiscardAllMode();
|
||||||
View = new Views.Discard { DataContext = this };
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Discard(Repository repo, List<Models.Change> changes)
|
public Discard(Repository repo, List<Models.Change> changes)
|
||||||
|
@ -56,8 +54,6 @@ namespace SourceGit.ViewModels
|
||||||
Mode = new DiscardSingleFile() { Path = _changes[0].Path };
|
Mode = new DiscardSingleFile() { Path = _changes[0].Path };
|
||||||
else
|
else
|
||||||
Mode = new DiscardMultipleFiles() { Count = _changes.Count };
|
Mode = new DiscardMultipleFiles() { Count = _changes.Count };
|
||||||
|
|
||||||
View = new Views.Discard() { DataContext = this };
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override Task<bool> Sure()
|
public override Task<bool> Sure()
|
||||||
|
|
|
@ -4,13 +4,12 @@ namespace SourceGit.ViewModels
|
||||||
{
|
{
|
||||||
public class DropStash : Popup
|
public class DropStash : Popup
|
||||||
{
|
{
|
||||||
public Models.Stash Stash { get; private set; }
|
public Models.Stash Stash { get; }
|
||||||
|
|
||||||
public DropStash(Repository repo, Models.Stash stash)
|
public DropStash(Repository repo, Models.Stash stash)
|
||||||
{
|
{
|
||||||
_repo = repo;
|
_repo = repo;
|
||||||
Stash = stash;
|
Stash = stash;
|
||||||
View = new Views.DropStash() { DataContext = this };
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override Task<bool> Sure()
|
public override Task<bool> Sure()
|
||||||
|
|
|
@ -56,8 +56,6 @@ namespace SourceGit.ViewModels
|
||||||
{
|
{
|
||||||
SSHKey = new Commands.Config(repo.FullPath).Get($"remote.{remote.Name}.sshkey");
|
SSHKey = new Commands.Config(repo.FullPath).Get($"remote.{remote.Name}.sshkey");
|
||||||
}
|
}
|
||||||
|
|
||||||
View = new Views.EditRemote() { DataContext = this };
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ValidationResult ValidateRemoteName(string name, ValidationContext ctx)
|
public static ValidationResult ValidateRemoteName(string name, ValidationContext ctx)
|
||||||
|
|
|
@ -37,8 +37,6 @@ namespace SourceGit.ViewModels
|
||||||
_name = node.Name;
|
_name = node.Name;
|
||||||
_isRepository = node.IsRepository;
|
_isRepository = node.IsRepository;
|
||||||
_bookmark = node.Bookmark;
|
_bookmark = node.Bookmark;
|
||||||
|
|
||||||
View = new Views.EditRepositoryNode() { DataContext = this };
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override Task<bool> Sure()
|
public override Task<bool> Sure()
|
||||||
|
|
|
@ -8,7 +8,6 @@ namespace SourceGit.ViewModels
|
||||||
public Models.CustomAction CustomAction
|
public Models.CustomAction CustomAction
|
||||||
{
|
{
|
||||||
get;
|
get;
|
||||||
private set;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public ExecuteCustomAction(Repository repo, Models.CustomAction action)
|
public ExecuteCustomAction(Repository repo, Models.CustomAction action)
|
||||||
|
@ -16,7 +15,6 @@ namespace SourceGit.ViewModels
|
||||||
_repo = repo;
|
_repo = repo;
|
||||||
_args = action.Arguments.Replace("${REPO}", GetWorkdir());
|
_args = action.Arguments.Replace("${REPO}", GetWorkdir());
|
||||||
CustomAction = action;
|
CustomAction = action;
|
||||||
View = new Views.ExecuteCustomAction() { DataContext = this };
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public ExecuteCustomAction(Repository repo, Models.CustomAction action, Models.Branch branch)
|
public ExecuteCustomAction(Repository repo, Models.CustomAction action, Models.Branch branch)
|
||||||
|
@ -24,7 +22,6 @@ namespace SourceGit.ViewModels
|
||||||
_repo = repo;
|
_repo = repo;
|
||||||
_args = action.Arguments.Replace("${REPO}", GetWorkdir()).Replace("${BRANCH}", branch.FriendlyName);
|
_args = action.Arguments.Replace("${REPO}", GetWorkdir()).Replace("${BRANCH}", branch.FriendlyName);
|
||||||
CustomAction = action;
|
CustomAction = action;
|
||||||
View = new Views.ExecuteCustomAction() { DataContext = this };
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public ExecuteCustomAction(Repository repo, Models.CustomAction action, Models.Commit commit)
|
public ExecuteCustomAction(Repository repo, Models.CustomAction action, Models.Commit commit)
|
||||||
|
@ -32,7 +29,6 @@ namespace SourceGit.ViewModels
|
||||||
_repo = repo;
|
_repo = repo;
|
||||||
_args = action.Arguments.Replace("${REPO}", GetWorkdir()).Replace("${SHA}", commit.SHA);
|
_args = action.Arguments.Replace("${REPO}", GetWorkdir()).Replace("${SHA}", commit.SHA);
|
||||||
CustomAction = action;
|
CustomAction = action;
|
||||||
View = new Views.ExecuteCustomAction() { DataContext = this };
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override Task<bool> Sure()
|
public override Task<bool> Sure()
|
||||||
|
@ -58,6 +54,6 @@ namespace SourceGit.ViewModels
|
||||||
}
|
}
|
||||||
|
|
||||||
private readonly Repository _repo = null;
|
private readonly Repository _repo = null;
|
||||||
private string _args = string.Empty;
|
private readonly string _args;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,13 +7,11 @@ namespace SourceGit.ViewModels
|
||||||
public Models.Branch Local
|
public Models.Branch Local
|
||||||
{
|
{
|
||||||
get;
|
get;
|
||||||
private set;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Models.Branch To
|
public Models.Branch To
|
||||||
{
|
{
|
||||||
get;
|
get;
|
||||||
private set;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public FastForwardWithoutCheckout(Repository repo, Models.Branch local, Models.Branch upstream)
|
public FastForwardWithoutCheckout(Repository repo, Models.Branch local, Models.Branch upstream)
|
||||||
|
@ -21,7 +19,6 @@ namespace SourceGit.ViewModels
|
||||||
_repo = repo;
|
_repo = repo;
|
||||||
Local = local;
|
Local = local;
|
||||||
To = upstream;
|
To = upstream;
|
||||||
View = new Views.FastForwardWithoutCheckout() { DataContext = this };
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override Task<bool> Sure()
|
public override Task<bool> Sure()
|
||||||
|
|
|
@ -55,8 +55,6 @@ namespace SourceGit.ViewModels
|
||||||
{
|
{
|
||||||
SelectedRemote = _repo.Remotes[0];
|
SelectedRemote = _repo.Remotes[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
View = new Views.Fetch() { DataContext = this };
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override Task<bool> Sure()
|
public override Task<bool> Sure()
|
||||||
|
|
|
@ -7,13 +7,11 @@ namespace SourceGit.ViewModels
|
||||||
public Models.Branch Local
|
public Models.Branch Local
|
||||||
{
|
{
|
||||||
get;
|
get;
|
||||||
private set;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Models.Branch Upstream
|
public Models.Branch Upstream
|
||||||
{
|
{
|
||||||
get;
|
get;
|
||||||
private set;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public FetchInto(Repository repo, Models.Branch local, Models.Branch upstream)
|
public FetchInto(Repository repo, Models.Branch local, Models.Branch upstream)
|
||||||
|
@ -21,7 +19,6 @@ namespace SourceGit.ViewModels
|
||||||
_repo = repo;
|
_repo = repo;
|
||||||
Local = local;
|
Local = local;
|
||||||
Upstream = upstream;
|
Upstream = upstream;
|
||||||
View = new Views.FetchInto() { DataContext = this };
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override Task<bool> Sure()
|
public override Task<bool> Sure()
|
||||||
|
|
|
@ -7,8 +7,7 @@ namespace SourceGit.ViewModels
|
||||||
public Models.Branch Branch
|
public Models.Branch Branch
|
||||||
{
|
{
|
||||||
get;
|
get;
|
||||||
set;
|
}
|
||||||
} = null;
|
|
||||||
|
|
||||||
public bool IsFeature => _type == "feature";
|
public bool IsFeature => _type == "feature";
|
||||||
public bool IsRelease => _type == "release";
|
public bool IsRelease => _type == "release";
|
||||||
|
@ -25,9 +24,7 @@ namespace SourceGit.ViewModels
|
||||||
_repo = repo;
|
_repo = repo;
|
||||||
_type = type;
|
_type = type;
|
||||||
_prefix = prefix;
|
_prefix = prefix;
|
||||||
|
|
||||||
Branch = branch;
|
Branch = branch;
|
||||||
View = new Views.GitFlowFinish() { DataContext = this };
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override Task<bool> Sure()
|
public override Task<bool> Sure()
|
||||||
|
|
|
@ -28,8 +28,6 @@ namespace SourceGit.ViewModels
|
||||||
_repo = repo;
|
_repo = repo;
|
||||||
_type = type;
|
_type = type;
|
||||||
_prefix = Commands.GitFlow.GetPrefix(repo.FullPath, type);
|
_prefix = Commands.GitFlow.GetPrefix(repo.FullPath, type);
|
||||||
|
|
||||||
View = new Views.GitFlowStart() { DataContext = this };
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ValidationResult ValidateBranchName(string name, ValidationContext ctx)
|
public static ValidationResult ValidateBranchName(string name, ValidationContext ctx)
|
||||||
|
|
|
@ -21,9 +21,7 @@ namespace SourceGit.ViewModels
|
||||||
_pageId = pageId;
|
_pageId = pageId;
|
||||||
_targetPath = path;
|
_targetPath = path;
|
||||||
_parentNode = parent;
|
_parentNode = parent;
|
||||||
|
|
||||||
Reason = string.IsNullOrEmpty(reason) ? "Invalid repository detected!" : reason;
|
Reason = string.IsNullOrEmpty(reason) ? "Invalid repository detected!" : reason;
|
||||||
View = new Views.Init() { DataContext = this };
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override Task<bool> Sure()
|
public override Task<bool> Sure()
|
||||||
|
@ -51,8 +49,8 @@ namespace SourceGit.ViewModels
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private string _pageId = null;
|
private readonly string _pageId = null;
|
||||||
private string _targetPath = null;
|
private string _targetPath = null;
|
||||||
private RepositoryNode _parentNode = null;
|
private readonly RepositoryNode _parentNode = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -78,8 +78,6 @@ namespace SourceGit.ViewModels
|
||||||
_master = localBranches[0];
|
_master = localBranches[0];
|
||||||
else
|
else
|
||||||
_master = "master";
|
_master = "master";
|
||||||
|
|
||||||
View = new Views.InitGitFlow() { DataContext = this };
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ValidationResult ValidateBaseBranch(string _, ValidationContext ctx)
|
public static ValidationResult ValidateBaseBranch(string _, ValidationContext ctx)
|
||||||
|
|
|
@ -17,7 +17,6 @@ namespace SourceGit.ViewModels
|
||||||
{
|
{
|
||||||
_repo = repo;
|
_repo = repo;
|
||||||
SelectedRemote = _repo.Remotes[0];
|
SelectedRemote = _repo.Remotes[0];
|
||||||
View = new Views.LFSFetch() { DataContext = this };
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override Task<bool> Sure()
|
public override Task<bool> Sure()
|
||||||
|
|
|
@ -7,7 +7,6 @@ namespace SourceGit.ViewModels
|
||||||
public LFSPrune(Repository repo)
|
public LFSPrune(Repository repo)
|
||||||
{
|
{
|
||||||
_repo = repo;
|
_repo = repo;
|
||||||
View = new Views.LFSPrune() { DataContext = this };
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override Task<bool> Sure()
|
public override Task<bool> Sure()
|
||||||
|
|
|
@ -17,7 +17,6 @@ namespace SourceGit.ViewModels
|
||||||
{
|
{
|
||||||
_repo = repo;
|
_repo = repo;
|
||||||
SelectedRemote = _repo.Remotes[0];
|
SelectedRemote = _repo.Remotes[0];
|
||||||
View = new Views.LFSPull() { DataContext = this };
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override Task<bool> Sure()
|
public override Task<bool> Sure()
|
||||||
|
|
|
@ -17,7 +17,6 @@ namespace SourceGit.ViewModels
|
||||||
{
|
{
|
||||||
_repo = repo;
|
_repo = repo;
|
||||||
SelectedRemote = _repo.Remotes[0];
|
SelectedRemote = _repo.Remotes[0];
|
||||||
View = new Views.LFSPush() { DataContext = this };
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override Task<bool> Sure()
|
public override Task<bool> Sure()
|
||||||
|
|
|
@ -21,7 +21,6 @@ namespace SourceGit.ViewModels
|
||||||
public LFSTrackCustomPattern(Repository repo)
|
public LFSTrackCustomPattern(Repository repo)
|
||||||
{
|
{
|
||||||
_repo = repo;
|
_repo = repo;
|
||||||
View = new Views.LFSTrackCustomPattern() { DataContext = this };
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override Task<bool> Sure()
|
public override Task<bool> Sure()
|
||||||
|
|
|
@ -29,7 +29,6 @@ namespace SourceGit.ViewModels
|
||||||
Source = source;
|
Source = source;
|
||||||
Into = into;
|
Into = into;
|
||||||
Mode = forceFastForward ? Models.MergeMode.Supported[1] : AutoSelectMergeMode();
|
Mode = forceFastForward ? Models.MergeMode.Supported[1] : AutoSelectMergeMode();
|
||||||
View = new Views.Merge() { DataContext = this };
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Merge(Repository repo, Models.Commit source, string into)
|
public Merge(Repository repo, Models.Commit source, string into)
|
||||||
|
@ -40,7 +39,6 @@ namespace SourceGit.ViewModels
|
||||||
Source = source;
|
Source = source;
|
||||||
Into = into;
|
Into = into;
|
||||||
Mode = AutoSelectMergeMode();
|
Mode = AutoSelectMergeMode();
|
||||||
View = new Views.Merge() { DataContext = this };
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Merge(Repository repo, Models.Tag source, string into)
|
public Merge(Repository repo, Models.Tag source, string into)
|
||||||
|
@ -51,7 +49,6 @@ namespace SourceGit.ViewModels
|
||||||
Source = source;
|
Source = source;
|
||||||
Into = into;
|
Into = into;
|
||||||
Mode = AutoSelectMergeMode();
|
Mode = AutoSelectMergeMode();
|
||||||
View = new Views.Merge() { DataContext = this };
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override Task<bool> Sure()
|
public override Task<bool> Sure()
|
||||||
|
@ -99,6 +96,6 @@ namespace SourceGit.ViewModels
|
||||||
}
|
}
|
||||||
|
|
||||||
private readonly Repository _repo = null;
|
private readonly Repository _repo = null;
|
||||||
private readonly string _sourceName = string.Empty;
|
private readonly string _sourceName;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,6 @@ namespace SourceGit.ViewModels
|
||||||
public List<object> Targets
|
public List<object> Targets
|
||||||
{
|
{
|
||||||
get;
|
get;
|
||||||
private set;
|
|
||||||
} = [];
|
} = [];
|
||||||
|
|
||||||
public bool AutoCommit
|
public bool AutoCommit
|
||||||
|
@ -29,7 +28,6 @@ namespace SourceGit.ViewModels
|
||||||
Targets.AddRange(commits);
|
Targets.AddRange(commits);
|
||||||
AutoCommit = true;
|
AutoCommit = true;
|
||||||
Strategy = Models.MergeStrategy.ForMultiple[0];
|
Strategy = Models.MergeStrategy.ForMultiple[0];
|
||||||
View = new Views.MergeMultiple() { DataContext = this };
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public MergeMultiple(Repository repo, List<Models.Branch> branches)
|
public MergeMultiple(Repository repo, List<Models.Branch> branches)
|
||||||
|
@ -38,7 +36,6 @@ namespace SourceGit.ViewModels
|
||||||
Targets.AddRange(branches);
|
Targets.AddRange(branches);
|
||||||
AutoCommit = true;
|
AutoCommit = true;
|
||||||
Strategy = Models.MergeStrategy.ForMultiple[0];
|
Strategy = Models.MergeStrategy.ForMultiple[0];
|
||||||
View = new Views.MergeMultiple() { DataContext = this };
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override Task<bool> Sure()
|
public override Task<bool> Sure()
|
||||||
|
|
|
@ -9,13 +9,11 @@ namespace SourceGit.ViewModels
|
||||||
public RepositoryNode Target
|
public RepositoryNode Target
|
||||||
{
|
{
|
||||||
get;
|
get;
|
||||||
private set;
|
|
||||||
} = null;
|
} = null;
|
||||||
|
|
||||||
public List<RepositoryNode> Rows
|
public List<RepositoryNode> Rows
|
||||||
{
|
{
|
||||||
get;
|
get;
|
||||||
private set;
|
|
||||||
} = [];
|
} = [];
|
||||||
|
|
||||||
public RepositoryNode Selected
|
public RepositoryNode Selected
|
||||||
|
@ -34,8 +32,6 @@ namespace SourceGit.ViewModels
|
||||||
Id = Guid.NewGuid().ToString()
|
Id = Guid.NewGuid().ToString()
|
||||||
});
|
});
|
||||||
MakeRows(Preferences.Instance.RepositoryNodes, 1);
|
MakeRows(Preferences.Instance.RepositoryNodes, 1);
|
||||||
|
|
||||||
View = new Views.MoveRepositoryNode() { DataContext = this };
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override Task<bool> Sure()
|
public override Task<bool> Sure()
|
||||||
|
|
|
@ -10,12 +10,6 @@ namespace SourceGit.ViewModels
|
||||||
{
|
{
|
||||||
public class Popup : ObservableValidator
|
public class Popup : ObservableValidator
|
||||||
{
|
{
|
||||||
public object View
|
|
||||||
{
|
|
||||||
get;
|
|
||||||
set;
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool InProgress
|
public bool InProgress
|
||||||
{
|
{
|
||||||
get => _inProgress;
|
get => _inProgress;
|
||||||
|
|
|
@ -7,14 +7,12 @@ namespace SourceGit.ViewModels
|
||||||
public Models.Remote Remote
|
public Models.Remote Remote
|
||||||
{
|
{
|
||||||
get;
|
get;
|
||||||
private set;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public PruneRemote(Repository repo, Models.Remote remote)
|
public PruneRemote(Repository repo, Models.Remote remote)
|
||||||
{
|
{
|
||||||
_repo = repo;
|
_repo = repo;
|
||||||
Remote = remote;
|
Remote = remote;
|
||||||
View = new Views.PruneRemote() { DataContext = this };
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override Task<bool> Sure()
|
public override Task<bool> Sure()
|
||||||
|
|
|
@ -7,7 +7,6 @@ namespace SourceGit.ViewModels
|
||||||
public PruneWorktrees(Repository repo)
|
public PruneWorktrees(Repository repo)
|
||||||
{
|
{
|
||||||
_repo = repo;
|
_repo = repo;
|
||||||
View = new Views.PruneWorktrees() { DataContext = this };
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override Task<bool> Sure()
|
public override Task<bool> Sure()
|
||||||
|
@ -27,6 +26,6 @@ namespace SourceGit.ViewModels
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private Repository _repo = null;
|
private readonly Repository _repo = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,7 +42,7 @@ namespace SourceGit.ViewModels
|
||||||
{
|
{
|
||||||
get;
|
get;
|
||||||
set;
|
set;
|
||||||
}
|
} = false;
|
||||||
|
|
||||||
public bool UseRebase
|
public bool UseRebase
|
||||||
{
|
{
|
||||||
|
@ -110,8 +110,6 @@ namespace SourceGit.ViewModels
|
||||||
PostRemoteSelected();
|
PostRemoteSelected();
|
||||||
HasSpecifiedRemoteBranch = false;
|
HasSpecifiedRemoteBranch = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
View = new Views.Pull() { DataContext = this };
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override Task<bool> Sure()
|
public override Task<bool> Sure()
|
||||||
|
|
|
@ -148,8 +148,6 @@ namespace SourceGit.ViewModels
|
||||||
|
|
||||||
// Auto select preferred remote branch.
|
// Auto select preferred remote branch.
|
||||||
AutoSelectBranchByRemote();
|
AutoSelectBranchByRemote();
|
||||||
|
|
||||||
View = new Views.Push() { DataContext = this };
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool CanStartDirectly()
|
public override bool CanStartDirectly()
|
||||||
|
|
|
@ -8,7 +8,6 @@ namespace SourceGit.ViewModels
|
||||||
public Models.Tag Target
|
public Models.Tag Target
|
||||||
{
|
{
|
||||||
get;
|
get;
|
||||||
private set;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Models.Remote> Remotes
|
public List<Models.Remote> Remotes
|
||||||
|
@ -33,7 +32,6 @@ namespace SourceGit.ViewModels
|
||||||
_repo = repo;
|
_repo = repo;
|
||||||
Target = target;
|
Target = target;
|
||||||
SelectedRemote = _repo.Remotes[0];
|
SelectedRemote = _repo.Remotes[0];
|
||||||
View = new Views.PushTag() { DataContext = this };
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override Task<bool> Sure()
|
public override Task<bool> Sure()
|
||||||
|
|
|
@ -29,7 +29,6 @@ namespace SourceGit.ViewModels
|
||||||
Current = current;
|
Current = current;
|
||||||
On = on;
|
On = on;
|
||||||
AutoStash = true;
|
AutoStash = true;
|
||||||
View = new Views.Rebase() { DataContext = this };
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Rebase(Repository repo, Models.Branch current, Models.Commit on)
|
public Rebase(Repository repo, Models.Branch current, Models.Commit on)
|
||||||
|
@ -39,7 +38,6 @@ namespace SourceGit.ViewModels
|
||||||
Current = current;
|
Current = current;
|
||||||
On = on;
|
On = on;
|
||||||
AutoStash = true;
|
AutoStash = true;
|
||||||
View = new Views.Rebase() { DataContext = this };
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override Task<bool> Sure()
|
public override Task<bool> Sure()
|
||||||
|
|
|
@ -7,8 +7,7 @@ namespace SourceGit.ViewModels
|
||||||
public Models.Worktree Target
|
public Models.Worktree Target
|
||||||
{
|
{
|
||||||
get;
|
get;
|
||||||
private set;
|
}
|
||||||
} = null;
|
|
||||||
|
|
||||||
public bool Force
|
public bool Force
|
||||||
{
|
{
|
||||||
|
@ -20,7 +19,6 @@ namespace SourceGit.ViewModels
|
||||||
{
|
{
|
||||||
_repo = repo;
|
_repo = repo;
|
||||||
Target = target;
|
Target = target;
|
||||||
View = new Views.RemoveWorktree() { DataContext = this };
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override Task<bool> Sure()
|
public override Task<bool> Sure()
|
||||||
|
@ -40,6 +38,6 @@ namespace SourceGit.ViewModels
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private Repository _repo = null;
|
private readonly Repository _repo = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,7 +25,6 @@ namespace SourceGit.ViewModels
|
||||||
_repo = repo;
|
_repo = repo;
|
||||||
_name = target.Name;
|
_name = target.Name;
|
||||||
Target = target;
|
Target = target;
|
||||||
View = new Views.RenameBranch() { DataContext = this };
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ValidationResult ValidateBranchName(string name, ValidationContext ctx)
|
public static ValidationResult ValidateBranchName(string name, ValidationContext ctx)
|
||||||
|
|
|
@ -7,13 +7,11 @@ namespace SourceGit.ViewModels
|
||||||
public Models.Branch Current
|
public Models.Branch Current
|
||||||
{
|
{
|
||||||
get;
|
get;
|
||||||
private set;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Models.Commit To
|
public Models.Commit To
|
||||||
{
|
{
|
||||||
get;
|
get;
|
||||||
private set;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Models.ResetMode SelectedMode
|
public Models.ResetMode SelectedMode
|
||||||
|
@ -28,7 +26,6 @@ namespace SourceGit.ViewModels
|
||||||
Current = current;
|
Current = current;
|
||||||
To = to;
|
To = to;
|
||||||
SelectedMode = Models.ResetMode.Supported[1];
|
SelectedMode = Models.ResetMode.Supported[1];
|
||||||
View = new Views.Reset() { DataContext = this };
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override Task<bool> Sure()
|
public override Task<bool> Sure()
|
||||||
|
|
|
@ -7,7 +7,6 @@ namespace SourceGit.ViewModels
|
||||||
public Models.Commit Target
|
public Models.Commit Target
|
||||||
{
|
{
|
||||||
get;
|
get;
|
||||||
private set;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool AutoCommit
|
public bool AutoCommit
|
||||||
|
@ -21,7 +20,6 @@ namespace SourceGit.ViewModels
|
||||||
_repo = repo;
|
_repo = repo;
|
||||||
Target = target;
|
Target = target;
|
||||||
AutoCommit = true;
|
AutoCommit = true;
|
||||||
View = new Views.Revert() { DataContext = this };
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override Task<bool> Sure()
|
public override Task<bool> Sure()
|
||||||
|
|
|
@ -9,7 +9,6 @@ namespace SourceGit.ViewModels
|
||||||
public Models.Commit Head
|
public Models.Commit Head
|
||||||
{
|
{
|
||||||
get;
|
get;
|
||||||
private set;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[Required(ErrorMessage = "Commit message is required!!!")]
|
[Required(ErrorMessage = "Commit message is required!!!")]
|
||||||
|
@ -24,9 +23,7 @@ namespace SourceGit.ViewModels
|
||||||
_repo = repo;
|
_repo = repo;
|
||||||
_oldMessage = new Commands.QueryCommitFullMessage(_repo.FullPath, head.SHA).Result();
|
_oldMessage = new Commands.QueryCommitFullMessage(_repo.FullPath, head.SHA).Result();
|
||||||
_message = _oldMessage;
|
_message = _oldMessage;
|
||||||
|
|
||||||
Head = head;
|
Head = head;
|
||||||
View = new Views.Reword() { DataContext = this };
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override Task<bool> Sure()
|
public override Task<bool> Sure()
|
||||||
|
@ -50,7 +47,7 @@ namespace SourceGit.ViewModels
|
||||||
}
|
}
|
||||||
|
|
||||||
private readonly Repository _repo;
|
private readonly Repository _repo;
|
||||||
|
private readonly string _oldMessage;
|
||||||
private string _message;
|
private string _message;
|
||||||
private string _oldMessage;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,15 +13,12 @@ namespace SourceGit.ViewModels
|
||||||
public string RootDir
|
public string RootDir
|
||||||
{
|
{
|
||||||
get;
|
get;
|
||||||
private set;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public ScanRepositories(string rootDir)
|
public ScanRepositories(string rootDir)
|
||||||
{
|
{
|
||||||
GetManagedRepositories(Preferences.Instance.RepositoryNodes, _managed);
|
GetManagedRepositories(Preferences.Instance.RepositoryNodes, _managed);
|
||||||
|
|
||||||
RootDir = rootDir;
|
RootDir = rootDir;
|
||||||
View = new Views.ScanRepositories() { DataContext = this };
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override Task<bool> Sure()
|
public override Task<bool> Sure()
|
||||||
|
|
|
@ -8,7 +8,6 @@ namespace SourceGit.ViewModels
|
||||||
public Models.Branch Local
|
public Models.Branch Local
|
||||||
{
|
{
|
||||||
get;
|
get;
|
||||||
private set;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Models.Branch> RemoteBranches
|
public List<Models.Branch> RemoteBranches
|
||||||
|
@ -49,8 +48,6 @@ namespace SourceGit.ViewModels
|
||||||
if (upstream != null)
|
if (upstream != null)
|
||||||
SelectedRemoteBranch = upstream;
|
SelectedRemoteBranch = upstream;
|
||||||
}
|
}
|
||||||
|
|
||||||
View = new Views.SetUpstream() { DataContext = this };
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override Task<bool> Sure()
|
public override Task<bool> Sure()
|
||||||
|
@ -75,7 +72,7 @@ namespace SourceGit.ViewModels
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private Repository _repo;
|
private readonly Repository _repo;
|
||||||
private bool _unset = false;
|
private bool _unset = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,7 @@ namespace SourceGit.ViewModels
|
||||||
{
|
{
|
||||||
public Models.Commit Target
|
public Models.Commit Target
|
||||||
{
|
{
|
||||||
get => _target;
|
get;
|
||||||
}
|
}
|
||||||
|
|
||||||
[Required(ErrorMessage = "Commit message is required!!!")]
|
[Required(ErrorMessage = "Commit message is required!!!")]
|
||||||
|
@ -20,10 +20,8 @@ namespace SourceGit.ViewModels
|
||||||
public Squash(Repository repo, Models.Commit target, string shaToGetPreferMessage)
|
public Squash(Repository repo, Models.Commit target, string shaToGetPreferMessage)
|
||||||
{
|
{
|
||||||
_repo = repo;
|
_repo = repo;
|
||||||
_target = target;
|
|
||||||
_message = new Commands.QueryCommitFullMessage(_repo.FullPath, shaToGetPreferMessage).Result();
|
_message = new Commands.QueryCommitFullMessage(_repo.FullPath, shaToGetPreferMessage).Result();
|
||||||
|
Target = target;
|
||||||
View = new Views.Squash() { DataContext = this };
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override Task<bool> Sure()
|
public override Task<bool> Sure()
|
||||||
|
@ -66,7 +64,6 @@ namespace SourceGit.ViewModels
|
||||||
}
|
}
|
||||||
|
|
||||||
private readonly Repository _repo;
|
private readonly Repository _repo;
|
||||||
private Models.Commit _target;
|
|
||||||
private string _message;
|
private string _message;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,8 +47,6 @@ namespace SourceGit.ViewModels
|
||||||
_repo = repo;
|
_repo = repo;
|
||||||
_changes = changes;
|
_changes = changes;
|
||||||
HasSelectedFiles = hasSelectedFiles;
|
HasSelectedFiles = hasSelectedFiles;
|
||||||
|
|
||||||
View = new Views.StashChanges() { DataContext = this };
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override Task<bool> Sure()
|
public override Task<bool> Sure()
|
||||||
|
|
|
@ -8,8 +8,7 @@ namespace SourceGit.ViewModels
|
||||||
public List<string> Submodules
|
public List<string> Submodules
|
||||||
{
|
{
|
||||||
get;
|
get;
|
||||||
private set;
|
} = [];
|
||||||
} = new List<string>();
|
|
||||||
|
|
||||||
public string SelectedSubmodule
|
public string SelectedSubmodule
|
||||||
{
|
{
|
||||||
|
@ -49,7 +48,6 @@ namespace SourceGit.ViewModels
|
||||||
Submodules.Add(submodule.Path);
|
Submodules.Add(submodule.Path);
|
||||||
|
|
||||||
SelectedSubmodule = Submodules.Count > 0 ? Submodules[0] : string.Empty;
|
SelectedSubmodule = Submodules.Count > 0 ? Submodules[0] : string.Empty;
|
||||||
View = new Views.UpdateSubmodules() { DataContext = this };
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override Task<bool> Sure()
|
public override Task<bool> Sure()
|
||||||
|
|
|
@ -67,7 +67,7 @@
|
||||||
<StackPanel Orientation="Vertical" Background="{DynamicResource Brush.Popup}">
|
<StackPanel Orientation="Vertical" Background="{DynamicResource Brush.Popup}">
|
||||||
<!-- Popup Widget -->
|
<!-- Popup Widget -->
|
||||||
<ContentPresenter Margin="8,16,8,8"
|
<ContentPresenter Margin="8,16,8,8"
|
||||||
Content="{Binding View}"
|
DataContextChanged="OnPopupDataContextChanged"
|
||||||
IsHitTestVisible="{Binding InProgress, Converter={x:Static BoolConverters.Not}}"/>
|
IsHitTestVisible="{Binding InProgress, Converter={x:Static BoolConverters.Not}}"/>
|
||||||
|
|
||||||
<!-- Options -->
|
<!-- Options -->
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
|
using System;
|
||||||
using Avalonia.Controls;
|
using Avalonia.Controls;
|
||||||
|
using Avalonia.Controls.Presenters;
|
||||||
using Avalonia.Input;
|
using Avalonia.Input;
|
||||||
using Avalonia.Interactivity;
|
using Avalonia.Interactivity;
|
||||||
|
|
||||||
|
@ -48,5 +50,35 @@ namespace SourceGit.Views
|
||||||
|
|
||||||
e.Handled = true;
|
e.Handled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void OnPopupDataContextChanged(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (sender is ContentPresenter presenter)
|
||||||
|
{
|
||||||
|
if (presenter.DataContext == null || presenter.DataContext is not ViewModels.Popup)
|
||||||
|
{
|
||||||
|
presenter.Content = null;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var dataTypeName = presenter.DataContext.GetType().FullName;
|
||||||
|
if (string.IsNullOrEmpty(dataTypeName))
|
||||||
|
{
|
||||||
|
presenter.Content = null;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var viewTypeName = dataTypeName.Replace("ViewModels", "Views");
|
||||||
|
var viewType = Type.GetType(viewTypeName);
|
||||||
|
if (viewType == null)
|
||||||
|
{
|
||||||
|
presenter.Content = null;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var view = Activator.CreateInstance(viewType);
|
||||||
|
presenter.Content = view;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue