mirror of
https://github.com/sourcegit-scm/sourcegit
synced 2025-05-22 12:45:00 +00:00
feature: add worktree support (#205)
This commit is contained in:
parent
43af8c49a1
commit
8a8aabede3
23 changed files with 959 additions and 21 deletions
|
@ -11,6 +11,7 @@ namespace SourceGit.Models
|
|||
string GitDir { get; set; }
|
||||
|
||||
void RefreshBranches();
|
||||
void RefreshWorktrees();
|
||||
void RefreshTags();
|
||||
void RefreshCommits();
|
||||
void RefreshSubmodules();
|
||||
|
@ -132,6 +133,7 @@ namespace SourceGit.Models
|
|||
}
|
||||
|
||||
Task.Run(_repo.RefreshWorkingCopyChanges);
|
||||
Task.Run(_repo.RefreshWorktrees);
|
||||
}
|
||||
|
||||
if (_updateWC > 0 && now > _updateWC)
|
||||
|
|
39
src/Models/Worktree.cs
Normal file
39
src/Models/Worktree.cs
Normal file
|
@ -0,0 +1,39 @@
|
|||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
|
||||
namespace SourceGit.Models
|
||||
{
|
||||
public class Worktree : ObservableObject
|
||||
{
|
||||
public string Branch { get; set; } = string.Empty;
|
||||
public string FullPath { get; set; } = string.Empty;
|
||||
public string Head { get; set; } = string.Empty;
|
||||
public bool IsBare { get; set; } = false;
|
||||
public bool IsDetached { get; set; } = false;
|
||||
public bool IsPrunable { get; set; } = false;
|
||||
|
||||
public bool IsLocked
|
||||
{
|
||||
get => _isLocked;
|
||||
set => SetProperty(ref _isLocked, value);
|
||||
}
|
||||
|
||||
public string Name
|
||||
{
|
||||
get
|
||||
{
|
||||
if (IsDetached)
|
||||
return $"(deteched HEAD at {Head.Substring(10)})";
|
||||
|
||||
if (Branch.StartsWith("refs/heads/", System.StringComparison.Ordinal))
|
||||
return $"({Branch.Substring(11)})";
|
||||
|
||||
if (Branch.StartsWith("refs/remotes/", System.StringComparison.Ordinal))
|
||||
return $"({Branch.Substring(13)})";
|
||||
|
||||
return $"({Branch})";
|
||||
}
|
||||
}
|
||||
|
||||
private bool _isLocked = false;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue