mirror of
https://github.com/sourcegit-scm/sourcegit.git
synced 2024-12-25 21:07:20 -08:00
Compare commits
4 commits
7c253637fc
...
204d5cecec
Author | SHA1 | Date | |
---|---|---|---|
|
204d5cecec | ||
|
0539a94cbe | ||
|
9668efbd8c | ||
|
45869c27b8 |
8 changed files with 90 additions and 59 deletions
|
@ -5,27 +5,27 @@ namespace SourceGit.Commands
|
|||
{
|
||||
public class Add : Command
|
||||
{
|
||||
public Add(string repo, List<Models.Change> changes = null)
|
||||
public Add(string repo, bool includeUntracked)
|
||||
{
|
||||
WorkingDirectory = repo;
|
||||
Context = repo;
|
||||
Args = includeUntracked ? "add ." : "add -u .";
|
||||
}
|
||||
|
||||
public Add(string repo, List<Models.Change> changes)
|
||||
{
|
||||
WorkingDirectory = repo;
|
||||
Context = repo;
|
||||
|
||||
if (changes == null || changes.Count == 0)
|
||||
var builder = new StringBuilder();
|
||||
builder.Append("add --");
|
||||
foreach (var c in changes)
|
||||
{
|
||||
Args = "add .";
|
||||
}
|
||||
else
|
||||
{
|
||||
var builder = new StringBuilder();
|
||||
builder.Append("add --");
|
||||
foreach (var c in changes)
|
||||
{
|
||||
builder.Append(" \"");
|
||||
builder.Append(c.Path);
|
||||
builder.Append("\"");
|
||||
}
|
||||
Args = builder.ToString();
|
||||
builder.Append(" \"");
|
||||
builder.Append(c.Path);
|
||||
builder.Append("\"");
|
||||
}
|
||||
Args = builder.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -89,8 +89,8 @@
|
|||
<x:String x:Key="Text.CherryPick.AppendSourceToMessage" xml:space="preserve">提交資訊中追加來源資訊</x:String>
|
||||
<x:String x:Key="Text.CherryPick.Commit" xml:space="preserve">提交列表:</x:String>
|
||||
<x:String x:Key="Text.CherryPick.CommitChanges" xml:space="preserve">提交變更</x:String>
|
||||
<x:String x:Key="Text.CherryPick.Mainline" xml:space="preserve">對比的父提交:</x:String>
|
||||
<x:String x:Key="Text.CherryPick.Mainline.Tips" xml:space="preserve">通常你不能對一個合併進行揀選,因為你不知道合併的哪一邊應該被視為主線。這個選項指定了作為主線的父提交,允許揀選相對於該提交的修改。</x:String>
|
||||
<x:String x:Key="Text.CherryPick.Mainline" xml:space="preserve">對比的父提交:</x:String>
|
||||
<x:String x:Key="Text.CherryPick.Mainline.Tips" xml:space="preserve">通常您不能對一個合併進行揀選 (cherry-pick),因為您不知道合併的哪一邊應該被視為主線。這個選項指定了作為主線的父提交,允許揀選相對於該提交的修改。</x:String>
|
||||
<x:String x:Key="Text.ClearStashes" xml:space="preserve">捨棄擱置變更確認</x:String>
|
||||
<x:String x:Key="Text.ClearStashes.Message" xml:space="preserve">您正在捨棄所有的擱置變更,一經操作便無法復原,是否繼續?</x:String>
|
||||
<x:String x:Key="Text.Clone" xml:space="preserve">複製 (clone) 遠端存放庫</x:String>
|
||||
|
@ -161,13 +161,13 @@
|
|||
<x:String x:Key="Text.ConfigureWorkspace" xml:space="preserve">工作區</x:String>
|
||||
<x:String x:Key="Text.ConfigureWorkspace.Color" xml:space="preserve">顏色</x:String>
|
||||
<x:String x:Key="Text.ConfigureWorkspace.Restore" xml:space="preserve">啟動時還原上次開啟的存放庫</x:String>
|
||||
<x:String x:Key="Text.ConventionalCommit" xml:space="preserve">規範化提交資訊生成</x:String>
|
||||
<x:String x:Key="Text.ConventionalCommit.BreakingChanges" xml:space="preserve">破壞性變更說明:</x:String>
|
||||
<x:String x:Key="Text.ConventionalCommit.ClosedIssue" xml:space="preserve">關閉的ISSUE:</x:String>
|
||||
<x:String x:Key="Text.ConventionalCommit.Detail" xml:space="preserve">詳細資訊:</x:String>
|
||||
<x:String x:Key="Text.ConventionalCommit.Scope" xml:space="preserve">模組:</x:String>
|
||||
<x:String x:Key="Text.ConventionalCommit.ShortDescription" xml:space="preserve">簡述:</x:String>
|
||||
<x:String x:Key="Text.ConventionalCommit.Type" xml:space="preserve">類型:</x:String>
|
||||
<x:String x:Key="Text.ConventionalCommit" xml:space="preserve">產生約定式提交訊息</x:String>
|
||||
<x:String x:Key="Text.ConventionalCommit.BreakingChanges" xml:space="preserve">破壞性變更:</x:String>
|
||||
<x:String x:Key="Text.ConventionalCommit.ClosedIssue" xml:space="preserve">關閉的 Issue:</x:String>
|
||||
<x:String x:Key="Text.ConventionalCommit.Detail" xml:space="preserve">詳細資訊:</x:String>
|
||||
<x:String x:Key="Text.ConventionalCommit.Scope" xml:space="preserve">模組:</x:String>
|
||||
<x:String x:Key="Text.ConventionalCommit.ShortDescription" xml:space="preserve">簡述:</x:String>
|
||||
<x:String x:Key="Text.ConventionalCommit.Type" xml:space="preserve">類型:</x:String>
|
||||
<x:String x:Key="Text.Copy" xml:space="preserve">複製</x:String>
|
||||
<x:String x:Key="Text.CopyAllText" xml:space="preserve">複製全部內容</x:String>
|
||||
<x:String x:Key="Text.CopyMessage" xml:space="preserve">複製內容</x:String>
|
||||
|
@ -528,7 +528,7 @@
|
|||
<x:String x:Key="Text.Repository.Search.ByMessage" xml:space="preserve">提交訊息</x:String>
|
||||
<x:String x:Key="Text.Repository.Search.BySHA" xml:space="preserve">提交編號</x:String>
|
||||
<x:String x:Key="Text.Repository.Search.ByUser" xml:space="preserve">作者及提交者</x:String>
|
||||
<x:String x:Key="Text.Repository.Search.InCurrentBranch" xml:space="preserve">僅搜尋當前分支</x:String>
|
||||
<x:String x:Key="Text.Repository.Search.InCurrentBranch" xml:space="preserve">僅搜尋目前分支</x:String>
|
||||
<x:String x:Key="Text.Repository.ShowTagsAsTree" xml:space="preserve">以樹型結構展示</x:String>
|
||||
<x:String x:Key="Text.Repository.Statistics" xml:space="preserve">提交統計</x:String>
|
||||
<x:String x:Key="Text.Repository.Submodules" xml:space="preserve">子模組列表</x:String>
|
||||
|
@ -574,7 +574,7 @@
|
|||
<x:String x:Key="Text.Stash.Message" xml:space="preserve">擱置變更訊息:</x:String>
|
||||
<x:String x:Key="Text.Stash.Message.Placeholder" xml:space="preserve">選填,用於命名此擱置變更</x:String>
|
||||
<x:String x:Key="Text.Stash.OnlyStagedChanges" xml:space="preserve">僅擱置已暫存的變更</x:String>
|
||||
<x:String x:Key="Text.Stash.TipForSelectedFiles" xml:space="preserve">選中檔案的所有變更均會被擱置!</x:String>
|
||||
<x:String x:Key="Text.Stash.TipForSelectedFiles" xml:space="preserve">已選取的檔案中的變更均會被擱置!</x:String>
|
||||
<x:String x:Key="Text.Stash.Title" xml:space="preserve">擱置本機變更</x:String>
|
||||
<x:String x:Key="Text.StashCM.Apply" xml:space="preserve">套用 (apply)</x:String>
|
||||
<x:String x:Key="Text.StashCM.Drop" xml:space="preserve">刪除 (drop)</x:String>
|
||||
|
|
|
@ -453,6 +453,13 @@ namespace SourceGit.ViewModels
|
|||
Save();
|
||||
}
|
||||
|
||||
public void AutoRemoveInvalidNode()
|
||||
{
|
||||
var changed = RemoveInvalidRepositoriesRecursive(RepositoryNodes);
|
||||
if (changed)
|
||||
Save();
|
||||
}
|
||||
|
||||
public void Save()
|
||||
{
|
||||
if (_isLoading)
|
||||
|
@ -567,6 +574,27 @@ namespace SourceGit.ViewModels
|
|||
return false;
|
||||
}
|
||||
|
||||
private bool RemoveInvalidRepositoriesRecursive(List<RepositoryNode> collection)
|
||||
{
|
||||
bool changed = false;
|
||||
|
||||
for (int i = collection.Count - 1; i >= 0; i--)
|
||||
{
|
||||
var node = collection[i];
|
||||
if (node.IsInvalid)
|
||||
{
|
||||
collection.RemoveAt(i);
|
||||
changed = true;
|
||||
}
|
||||
else if (!node.IsRepository)
|
||||
{
|
||||
changed |= RemoveInvalidRepositoriesRecursive(node.SubNodes);
|
||||
}
|
||||
}
|
||||
|
||||
return changed;
|
||||
}
|
||||
|
||||
private static Preference _instance = null;
|
||||
private static bool _isLoading = false;
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
|
@ -48,6 +49,12 @@ namespace SourceGit.ViewModels
|
|||
set => SetProperty(ref _isVisible, value);
|
||||
}
|
||||
|
||||
[JsonIgnore]
|
||||
public bool IsInvalid
|
||||
{
|
||||
get => _isRepository && !Directory.Exists(_id);
|
||||
}
|
||||
|
||||
[JsonIgnore]
|
||||
public int Depth
|
||||
{
|
||||
|
|
|
@ -56,12 +56,9 @@ namespace SourceGit.ViewModels
|
|||
var group = FindOrCreateGroupRecursive(Preference.Instance.RepositoryNodes, relative);
|
||||
Preference.Instance.FindOrAddNodeByRepositoryPath(f, group, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Should not happen.
|
||||
}
|
||||
}
|
||||
|
||||
Preference.Instance.AutoRemoveInvalidNode();
|
||||
Welcome.Instance.Refresh();
|
||||
});
|
||||
|
||||
|
|
|
@ -345,7 +345,7 @@ namespace SourceGit.ViewModels
|
|||
_repo.SetWatcherEnabled(false);
|
||||
if (changes.Count == _unstaged.Count)
|
||||
{
|
||||
await Task.Run(() => new Commands.Add(_repo.FullPath).Exec());
|
||||
await Task.Run(() => new Commands.Add(_repo.FullPath, _repo.IncludeUntracked).Exec());
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1316,7 +1316,7 @@ namespace SourceGit.ViewModels
|
|||
{
|
||||
var succ = true;
|
||||
if (autoStage && _unstaged.Count > 0)
|
||||
succ = new Commands.Add(_repo.FullPath).Exec();
|
||||
succ = new Commands.Add(_repo.FullPath, _repo.IncludeUntracked).Exec();
|
||||
|
||||
if (succ)
|
||||
succ = new Commands.Commit(_repo.FullPath, _commitMessage, _useAmend).Exec();
|
||||
|
|
|
@ -216,29 +216,23 @@
|
|||
HorizontalAlignment="Stretch" VerticalAlignment="Stretch"
|
||||
Background="{DynamicResource Brush.Window}"
|
||||
BorderBrush="{DynamicResource Brush.Border0}"/>
|
||||
|
||||
<Grid Grid.Row="2" Grid.Column="0" Grid.ColumnSpan="3">
|
||||
<Grid IsVisible="{Binding DetailContext, Converter={x:Static ObjectConverters.IsNull}}">
|
||||
<Path Width="128" Height="128"
|
||||
Data="{StaticResource Icons.Detail}"
|
||||
HorizontalAlignment="Center"
|
||||
Fill="{DynamicResource Brush.FG2}"/>
|
||||
|
||||
<Border Grid.Row="2" Grid.Column="0" Grid.ColumnSpan="3">
|
||||
<ContentControl>
|
||||
<ContentControl.Content>
|
||||
<Binding Path="DetailContext">
|
||||
<Binding.TargetNullValue>
|
||||
<Grid>
|
||||
<Path Width="128" Height="128"
|
||||
Data="{StaticResource Icons.Detail}"
|
||||
HorizontalAlignment="Center"
|
||||
Fill="{DynamicResource Brush.FG2}"/>
|
||||
|
||||
<StackPanel Margin="0,8" Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Bottom">
|
||||
<Path Width="12" Height="12" VerticalAlignment="Center" Data="{StaticResource Icons.Info}" Fill="{DynamicResource Brush.FG2}"/>
|
||||
<TextBlock Margin="4,0" Text="{DynamicResource Text.Histories.Tips.Prefix}" FontWeight="Bold" Foreground="{DynamicResource Brush.FG2}"/>
|
||||
<TextBlock Text="{DynamicResource Text.Histories.Tips}" Foreground="{DynamicResource Brush.FG2}" IsVisible="{OnPlatform True, macOS=False}"/>
|
||||
<TextBlock Text="{DynamicResource Text.Histories.Tips.MacOS}" Foreground="{DynamicResource Brush.FG2}" IsVisible="{OnPlatform False, macOS=True}"/>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</Binding.TargetNullValue>
|
||||
</Binding>
|
||||
</ContentControl.Content>
|
||||
|
||||
<StackPanel Margin="0,8" Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Bottom">
|
||||
<Path Width="12" Height="12" VerticalAlignment="Center" Data="{StaticResource Icons.Info}" Fill="{DynamicResource Brush.FG2}"/>
|
||||
<TextBlock Margin="4,0" Text="{DynamicResource Text.Histories.Tips.Prefix}" FontWeight="Bold" Foreground="{DynamicResource Brush.FG2}"/>
|
||||
<TextBlock Text="{DynamicResource Text.Histories.Tips}" Foreground="{DynamicResource Brush.FG2}" IsVisible="{OnPlatform True, macOS=False}"/>
|
||||
<TextBlock Text="{DynamicResource Text.Histories.Tips.MacOS}" Foreground="{DynamicResource Brush.FG2}" IsVisible="{OnPlatform False, macOS=True}"/>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
|
||||
<ContentControl Content="{Binding DetailContext}">
|
||||
<ContentControl.DataTemplates>
|
||||
<DataTemplate DataType="vm:CommitDetail">
|
||||
<v:CommitDetail/>
|
||||
|
@ -264,6 +258,6 @@
|
|||
</DataTemplate>
|
||||
</ContentControl.DataTemplates>
|
||||
</ContentControl>
|
||||
</Border>
|
||||
</Grid>
|
||||
</v:LayoutableGrid>
|
||||
</UserControl>
|
||||
|
|
|
@ -131,10 +131,15 @@
|
|||
IsChecked="{Binding IsExpanded}"
|
||||
IsVisible="{Binding !IsRepository}"/>
|
||||
|
||||
<TextBlock Grid.Column="2"
|
||||
Classes="primary"
|
||||
VerticalAlignment="Center"
|
||||
Text="{Binding Name}"/>
|
||||
<StackPanel Grid.Column="2" Orientation="Horizontal">
|
||||
<TextBlock Classes="primary" VerticalAlignment="Center" Text="{Binding Name}"/>
|
||||
<Path Margin="2,0,0,0"
|
||||
Width="12" Height="12"
|
||||
Data="{StaticResource Icons.Error}"
|
||||
Fill="Orange"
|
||||
IsVisible="{Binding IsInvalid}"/>
|
||||
</StackPanel>
|
||||
|
||||
<TextBlock Grid.Column="3"
|
||||
Classes="primary"
|
||||
Margin="8,0"
|
||||
|
|
Loading…
Reference in a new issue