mirror of
https://github.com/sourcegit-scm/sourcegit.git
synced 2024-12-26 21:17:20 -08:00
Compare commits
5 commits
4e57cd50cd
...
3ce06cc6b5
Author | SHA1 | Date | |
---|---|---|---|
|
3ce06cc6b5 | ||
|
5005b62eea | ||
|
af099af4d0 | ||
|
ad3eec99cf | ||
|
6fe7dfad7f |
7 changed files with 91 additions and 55 deletions
|
@ -41,11 +41,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "_common", "_common", "{04FD
|
||||||
EndProject
|
EndProject
|
||||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "usr", "usr", "{76639799-54BC-45E8-BD90-F45F63ACD11D}"
|
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "usr", "usr", "{76639799-54BC-45E8-BD90-F45F63ACD11D}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "bin", "bin", "{2E27E952-846B-4D75-A426-D22151277864}"
|
|
||||||
ProjectSection(SolutionItems) = preProject
|
|
||||||
build\resources\_common\usr\bin\sourcegit = build\resources\_common\usr\bin\sourcegit
|
|
||||||
EndProjectSection
|
|
||||||
EndProject
|
|
||||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "share", "share", "{A3ABAA7C-EE14-4448-B466-6E69C1347E7D}"
|
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "share", "share", "{A3ABAA7C-EE14-4448-B466-6E69C1347E7D}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "applications", "applications", "{2AF28D3B-14A8-46A8-B828-157FAAB1B06F}"
|
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "applications", "applications", "{2AF28D3B-14A8-46A8-B828-157FAAB1B06F}"
|
||||||
|
@ -106,7 +101,6 @@ Global
|
||||||
{ABC98884-F023-4EF4-A9C9-5DE9452BE955} = {FD384607-ED99-47B7-AF31-FB245841BC92}
|
{ABC98884-F023-4EF4-A9C9-5DE9452BE955} = {FD384607-ED99-47B7-AF31-FB245841BC92}
|
||||||
{04FD74B1-FBDB-496E-A48F-3D59D71FF952} = {FD384607-ED99-47B7-AF31-FB245841BC92}
|
{04FD74B1-FBDB-496E-A48F-3D59D71FF952} = {FD384607-ED99-47B7-AF31-FB245841BC92}
|
||||||
{76639799-54BC-45E8-BD90-F45F63ACD11D} = {04FD74B1-FBDB-496E-A48F-3D59D71FF952}
|
{76639799-54BC-45E8-BD90-F45F63ACD11D} = {04FD74B1-FBDB-496E-A48F-3D59D71FF952}
|
||||||
{2E27E952-846B-4D75-A426-D22151277864} = {76639799-54BC-45E8-BD90-F45F63ACD11D}
|
|
||||||
{A3ABAA7C-EE14-4448-B466-6E69C1347E7D} = {76639799-54BC-45E8-BD90-F45F63ACD11D}
|
{A3ABAA7C-EE14-4448-B466-6E69C1347E7D} = {76639799-54BC-45E8-BD90-F45F63ACD11D}
|
||||||
{2AF28D3B-14A8-46A8-B828-157FAAB1B06F} = {A3ABAA7C-EE14-4448-B466-6E69C1347E7D}
|
{2AF28D3B-14A8-46A8-B828-157FAAB1B06F} = {A3ABAA7C-EE14-4448-B466-6E69C1347E7D}
|
||||||
{7166EC6C-17F5-4B5E-B38E-1E53C81EACF6} = {A3ABAA7C-EE14-4448-B466-6E69C1347E7D}
|
{7166EC6C-17F5-4B5E-B38E-1E53C81EACF6} = {A3ABAA7C-EE14-4448-B466-6E69C1347E7D}
|
||||||
|
|
|
@ -17,9 +17,20 @@ namespace SourceGit.Commands
|
||||||
return Exec();
|
return Exec();
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool Push(List<Models.Change> changes, string message)
|
public bool Push(List<Models.Change> changes, string message, bool onlyStaged)
|
||||||
{
|
{
|
||||||
var pathsBuilder = new StringBuilder();
|
var pathsBuilder = new StringBuilder();
|
||||||
|
|
||||||
|
if (onlyStaged)
|
||||||
|
{
|
||||||
|
foreach (var c in changes)
|
||||||
|
pathsBuilder.Append($"\"{c.Path}\" ");
|
||||||
|
|
||||||
|
var paths = pathsBuilder.ToString();
|
||||||
|
Args = $"stash push --staged -m \"{message}\" -- {paths}";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
var needAdd = new List<Models.Change>();
|
var needAdd = new List<Models.Change>();
|
||||||
foreach (var c in changes)
|
foreach (var c in changes)
|
||||||
{
|
{
|
||||||
|
@ -43,6 +54,8 @@ namespace SourceGit.Commands
|
||||||
|
|
||||||
var paths = pathsBuilder.ToString();
|
var paths = pathsBuilder.ToString();
|
||||||
Args = $"stash push -m \"{message}\" -- {paths}";
|
Args = $"stash push -m \"{message}\" -- {paths}";
|
||||||
|
}
|
||||||
|
|
||||||
return Exec();
|
return Exec();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,6 @@ namespace SourceGit.ViewModels
|
||||||
public Models.Branch Target
|
public Models.Branch Target
|
||||||
{
|
{
|
||||||
get;
|
get;
|
||||||
private set;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[Required(ErrorMessage = "Branch name is required!!!")]
|
[Required(ErrorMessage = "Branch name is required!!!")]
|
||||||
|
@ -54,8 +53,19 @@ namespace SourceGit.ViewModels
|
||||||
|
|
||||||
return Task.Run(() =>
|
return Task.Run(() =>
|
||||||
{
|
{
|
||||||
|
var oldName = Target.FullName;
|
||||||
var succ = Commands.Branch.Rename(_repo.FullPath, Target.Name, _name);
|
var succ = Commands.Branch.Rename(_repo.FullPath, Target.Name, _name);
|
||||||
CallUIThread(() => _repo.SetWatcherEnabled(true));
|
CallUIThread(() =>
|
||||||
|
{
|
||||||
|
if (succ && _repo.Settings.Filters.Contains(oldName))
|
||||||
|
{
|
||||||
|
_repo.Settings.Filters.Remove(oldName);
|
||||||
|
_repo.Settings.Filters.Add($"refs/heads/{_name}");
|
||||||
|
}
|
||||||
|
|
||||||
|
_repo.MarkBranchesDirtyManually();
|
||||||
|
_repo.SetWatcherEnabled(true);
|
||||||
|
});
|
||||||
return succ;
|
return succ;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -841,7 +841,7 @@ namespace SourceGit.ViewModels
|
||||||
|
|
||||||
if (_settings.Filters.Count != validFilters.Count)
|
if (_settings.Filters.Count != validFilters.Count)
|
||||||
{
|
{
|
||||||
Dispatcher.UIThread.Post(() =>
|
Dispatcher.UIThread.Invoke(() =>
|
||||||
{
|
{
|
||||||
_settings.Filters.Clear();
|
_settings.Filters.Clear();
|
||||||
_settings.Filters.AddRange(validFilters);
|
_settings.Filters.AddRange(validFilters);
|
||||||
|
@ -850,6 +850,9 @@ namespace SourceGit.ViewModels
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
if (_settings.Filters.Count != 0)
|
||||||
|
Dispatcher.UIThread.Invoke(() => _settings.Filters.Clear());
|
||||||
|
|
||||||
limits += "--exclude=refs/stash --all";
|
limits += "--exclude=refs/stash --all";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,6 @@ namespace SourceGit.ViewModels
|
||||||
public bool CanIgnoreUntracked
|
public bool CanIgnoreUntracked
|
||||||
{
|
{
|
||||||
get;
|
get;
|
||||||
private set;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool IncludeUntracked
|
public bool IncludeUntracked
|
||||||
|
@ -23,10 +22,11 @@ namespace SourceGit.ViewModels
|
||||||
set;
|
set;
|
||||||
}
|
}
|
||||||
|
|
||||||
public StashChanges(Repository repo, List<Models.Change> changes, bool canIgnoreUntracked)
|
public StashChanges(Repository repo, List<Models.Change> changes, bool onlyStaged, bool canIgnoreUntracked)
|
||||||
{
|
{
|
||||||
_repo = repo;
|
_repo = repo;
|
||||||
_changes = changes;
|
_changes = changes;
|
||||||
|
_onlyStaged = onlyStaged;
|
||||||
|
|
||||||
CanIgnoreUntracked = canIgnoreUntracked;
|
CanIgnoreUntracked = canIgnoreUntracked;
|
||||||
IncludeUntracked = true;
|
IncludeUntracked = true;
|
||||||
|
@ -56,17 +56,18 @@ namespace SourceGit.ViewModels
|
||||||
|
|
||||||
return Task.Run(() =>
|
return Task.Run(() =>
|
||||||
{
|
{
|
||||||
new Commands.Stash(_repo.FullPath).Push(jobs, Message);
|
var succ = new Commands.Stash(_repo.FullPath).Push(jobs, Message, _onlyStaged);
|
||||||
CallUIThread(() =>
|
CallUIThread(() =>
|
||||||
{
|
{
|
||||||
_repo.MarkWorkingCopyDirtyManually();
|
_repo.MarkWorkingCopyDirtyManually();
|
||||||
_repo.SetWatcherEnabled(true);
|
_repo.SetWatcherEnabled(true);
|
||||||
});
|
});
|
||||||
return true;
|
return succ;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private readonly Repository _repo = null;
|
private readonly Repository _repo = null;
|
||||||
private readonly List<Models.Change> _changes = null;
|
private readonly List<Models.Change> _changes = null;
|
||||||
|
private readonly bool _onlyStaged = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -318,9 +318,9 @@ namespace SourceGit.ViewModels
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (autoStart)
|
if (autoStart)
|
||||||
PopupHost.ShowAndStartPopup(new StashChanges(_repo, _cached, true));
|
PopupHost.ShowAndStartPopup(new StashChanges(_repo, _cached, false, true));
|
||||||
else
|
else
|
||||||
PopupHost.ShowPopup(new StashChanges(_repo, _cached, true));
|
PopupHost.ShowPopup(new StashChanges(_repo, _cached, false, true));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void StageSelected(Models.Change next)
|
public void StageSelected(Models.Change next)
|
||||||
|
@ -524,7 +524,7 @@ namespace SourceGit.ViewModels
|
||||||
{
|
{
|
||||||
if (PopupHost.CanCreatePopup())
|
if (PopupHost.CanCreatePopup())
|
||||||
{
|
{
|
||||||
PopupHost.ShowPopup(new StashChanges(_repo, _selectedUnstaged, false));
|
PopupHost.ShowPopup(new StashChanges(_repo, _selectedUnstaged, false, false));
|
||||||
}
|
}
|
||||||
e.Handled = true;
|
e.Handled = true;
|
||||||
};
|
};
|
||||||
|
@ -843,7 +843,7 @@ namespace SourceGit.ViewModels
|
||||||
stash.Click += (_, e) =>
|
stash.Click += (_, e) =>
|
||||||
{
|
{
|
||||||
if (PopupHost.CanCreatePopup())
|
if (PopupHost.CanCreatePopup())
|
||||||
PopupHost.ShowPopup(new StashChanges(_repo, _selectedUnstaged, false));
|
PopupHost.ShowPopup(new StashChanges(_repo, _selectedUnstaged, false, false));
|
||||||
|
|
||||||
e.Handled = true;
|
e.Handled = true;
|
||||||
};
|
};
|
||||||
|
@ -928,7 +928,7 @@ namespace SourceGit.ViewModels
|
||||||
stash.Click += (_, e) =>
|
stash.Click += (_, e) =>
|
||||||
{
|
{
|
||||||
if (PopupHost.CanCreatePopup())
|
if (PopupHost.CanCreatePopup())
|
||||||
PopupHost.ShowPopup(new StashChanges(_repo, _selectedStaged, false));
|
PopupHost.ShowPopup(new StashChanges(_repo, _selectedStaged, true, false));
|
||||||
|
|
||||||
e.Handled = true;
|
e.Handled = true;
|
||||||
};
|
};
|
||||||
|
@ -1097,7 +1097,7 @@ namespace SourceGit.ViewModels
|
||||||
stash.Click += (_, e) =>
|
stash.Click += (_, e) =>
|
||||||
{
|
{
|
||||||
if (PopupHost.CanCreatePopup())
|
if (PopupHost.CanCreatePopup())
|
||||||
PopupHost.ShowPopup(new StashChanges(_repo, _selectedStaged, false));
|
PopupHost.ShowPopup(new StashChanges(_repo, _selectedStaged, true, false));
|
||||||
|
|
||||||
e.Handled = true;
|
e.Handled = true;
|
||||||
};
|
};
|
||||||
|
@ -1202,11 +1202,8 @@ namespace SourceGit.ViewModels
|
||||||
private List<Models.Change> GetStagedChanges()
|
private List<Models.Change> GetStagedChanges()
|
||||||
{
|
{
|
||||||
if (_useAmend)
|
if (_useAmend)
|
||||||
{
|
|
||||||
return new Commands.QueryStagedChangesWithAmend(_repo.FullPath).Result();
|
return new Commands.QueryStagedChangesWithAmend(_repo.FullPath).Result();
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
var rs = new List<Models.Change>();
|
var rs = new List<Models.Change>();
|
||||||
foreach (var c in _cached)
|
foreach (var c in _cached)
|
||||||
{
|
{
|
||||||
|
@ -1216,7 +1213,6 @@ namespace SourceGit.ViewModels
|
||||||
}
|
}
|
||||||
return rs;
|
return rs;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private void SetDetail(Models.Change change, bool isUnstaged)
|
private void SetDetail(Models.Change change, bool isUnstaged)
|
||||||
{
|
{
|
||||||
|
|
|
@ -62,6 +62,7 @@ namespace SourceGit.Views
|
||||||
];
|
];
|
||||||
|
|
||||||
private static readonly string[] INDICATOR = ["?", "±", "T", "+", "−", "➜", "❏", "U", "★"];
|
private static readonly string[] INDICATOR = ["?", "±", "T", "+", "−", "➜", "❏", "U", "★"];
|
||||||
|
private static readonly string[] TIPS = ["Unknown", "Modified", "Type Changed", "Added", "Deleted", "Renamed", "Copied", "Unmerged", "Untracked" ];
|
||||||
|
|
||||||
public static readonly StyledProperty<bool> IsUnstagedChangeProperty =
|
public static readonly StyledProperty<bool> IsUnstagedChangeProperty =
|
||||||
AvaloniaProperty.Register<ChangeStatusIcon, bool>(nameof(IsUnstagedChange));
|
AvaloniaProperty.Register<ChangeStatusIcon, bool>(nameof(IsUnstagedChange));
|
||||||
|
@ -81,11 +82,6 @@ namespace SourceGit.Views
|
||||||
set => SetValue(ChangeProperty, value);
|
set => SetValue(ChangeProperty, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
static ChangeStatusIcon()
|
|
||||||
{
|
|
||||||
AffectsRender<ChangeStatusIcon>(IsUnstagedChangeProperty, ChangeProperty);
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void Render(DrawingContext context)
|
public override void Render(DrawingContext context)
|
||||||
{
|
{
|
||||||
if (Change == null || Bounds.Width <= 0)
|
if (Change == null || Bounds.Width <= 0)
|
||||||
|
@ -122,10 +118,33 @@ namespace SourceGit.Views
|
||||||
Bounds.Width * 0.8,
|
Bounds.Width * 0.8,
|
||||||
Brushes.White);
|
Brushes.White);
|
||||||
|
|
||||||
float corner = (float)Math.Max(2, Bounds.Width / 16);
|
var corner = (float)Math.Max(2, Bounds.Width / 16);
|
||||||
Point textOrigin = new Point((Bounds.Width - txt.Width) * 0.5, (Bounds.Height - txt.Height) * 0.5);
|
var textOrigin = new Point((Bounds.Width - txt.Width) * 0.5, (Bounds.Height - txt.Height) * 0.5);
|
||||||
context.DrawRectangle(background, null, new Rect(0, 0, Bounds.Width, Bounds.Height), corner, corner);
|
context.DrawRectangle(background, null, new Rect(0, 0, Bounds.Width, Bounds.Height), corner, corner);
|
||||||
context.DrawText(txt, textOrigin);
|
context.DrawText(txt, textOrigin);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override void OnPropertyChanged(AvaloniaPropertyChangedEventArgs change)
|
||||||
|
{
|
||||||
|
base.OnPropertyChanged(change);
|
||||||
|
|
||||||
|
if (change.Property == IsUnstagedChangeProperty || change.Property == ChangeProperty)
|
||||||
|
{
|
||||||
|
var isUnstaged = IsUnstagedChange;
|
||||||
|
var c = Change;
|
||||||
|
if (c == null)
|
||||||
|
{
|
||||||
|
ToolTip.SetTip(this, null);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isUnstaged)
|
||||||
|
ToolTip.SetTip(this, c.IsConflit ? "Conflict" : TIPS[(int)c.WorkTree]);
|
||||||
|
else
|
||||||
|
ToolTip.SetTip(this, TIPS[(int)c.Index]);
|
||||||
|
|
||||||
|
InvalidateVisual();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue