2024-03-17 18:37:06 -07:00
using System ;
2024-02-05 23:08:37 -08:00
using System.Collections.Generic ;
using System.IO ;
2024-06-30 20:57:13 -07:00
using System.Text.Json ;
2024-02-05 23:08:37 -08:00
using System.Threading.Tasks ;
2024-07-30 00:59:54 -07:00
using Avalonia.Collections ;
2024-03-17 18:37:06 -07:00
using Avalonia.Controls ;
2024-04-05 22:14:22 -07:00
using Avalonia.Media ;
using Avalonia.Media.Imaging ;
2024-03-17 18:37:06 -07:00
using Avalonia.Threading ;
using CommunityToolkit.Mvvm.ComponentModel ;
namespace SourceGit.ViewModels
{
public class Repository : ObservableObject , Models . IRepository
{
public string FullPath
{
2024-02-05 23:08:37 -08:00
get = > _fullpath ;
2024-03-17 18:37:06 -07:00
set
{
if ( value ! = null )
{
2024-02-29 21:40:12 -08:00
var normalized = value . Replace ( '\\' , '/' ) ;
SetProperty ( ref _fullpath , normalized ) ;
2024-03-17 18:37:06 -07:00
}
else
{
2024-02-29 21:40:12 -08:00
SetProperty ( ref _fullpath , null ) ;
}
}
2024-02-05 23:08:37 -08:00
}
2024-03-17 18:37:06 -07:00
public string GitDir
{
2024-02-05 23:08:37 -08:00
get = > _gitDir ;
set = > SetProperty ( ref _gitDir , value ) ;
}
2024-07-22 23:52:25 -07:00
public Models . RepositorySettings Settings
2024-06-19 00:36:49 -07:00
{
2024-06-30 20:57:13 -07:00
get = > _settings ;
}
2024-02-05 23:08:37 -08:00
2024-03-17 18:37:06 -07:00
public int SelectedViewIndex
{
2024-02-05 23:08:37 -08:00
get = > _selectedViewIndex ;
2024-03-17 18:37:06 -07:00
set
{
if ( SetProperty ( ref _selectedViewIndex , value ) )
{
switch ( value )
{
case 1 :
SelectedView = _workingCopy ;
break ;
case 2 :
SelectedView = _stashesPage ;
break ;
default :
SelectedView = _histories ;
break ;
2024-02-05 23:08:37 -08:00
}
}
}
}
2024-03-17 18:37:06 -07:00
public object SelectedView
{
2024-02-05 23:08:37 -08:00
get = > _selectedView ;
set = > SetProperty ( ref _selectedView , value ) ;
}
2024-08-21 04:45:32 -07:00
public bool EnableFirstParentInHistories
{
get = > _enableFirstParentInHistories ;
set
{
if ( SetProperty ( ref _enableFirstParentInHistories , value ) )
Task . Run ( RefreshCommits ) ;
}
}
2024-05-13 20:47:56 -07:00
public string SearchBranchFilter
{
get = > _searchBranchFilter ;
set
{
if ( SetProperty ( ref _searchBranchFilter , value ) )
{
var builder = BuildBranchTree ( _branches , _remotes ) ;
LocalBranchTrees = builder . Locals ;
RemoteBranchTrees = builder . Remotes ;
2024-06-27 06:43:15 -07:00
VisibleTags = BuildVisibleTags ( ) ;
2024-05-13 20:47:56 -07:00
}
}
}
2024-03-17 18:37:06 -07:00
public List < Models . Remote > Remotes
{
2024-02-05 23:08:37 -08:00
get = > _remotes ;
private set = > SetProperty ( ref _remotes , value ) ;
}
2024-03-17 18:37:06 -07:00
public List < Models . Branch > Branches
{
2024-02-05 23:08:37 -08:00
get = > _branches ;
private set = > SetProperty ( ref _branches , value ) ;
}
2024-07-24 00:36:26 -07:00
public Models . Branch CurrentBranch
{
get = > _currentBranch ;
private set = > SetProperty ( ref _currentBranch , value ) ;
}
2024-05-13 20:47:56 -07:00
public List < BranchTreeNode > LocalBranchTrees
2024-03-17 18:37:06 -07:00
{
2024-02-05 23:08:37 -08:00
get = > _localBranchTrees ;
private set = > SetProperty ( ref _localBranchTrees , value ) ;
}
2024-05-13 20:47:56 -07:00
public List < BranchTreeNode > RemoteBranchTrees
2024-03-17 18:37:06 -07:00
{
2024-02-05 23:08:37 -08:00
get = > _remoteBranchTrees ;
private set = > SetProperty ( ref _remoteBranchTrees , value ) ;
}
2024-06-27 03:25:16 -07:00
public List < Models . Worktree > Worktrees
{
get = > _worktrees ;
private set = > SetProperty ( ref _worktrees , value ) ;
}
2024-03-17 18:37:06 -07:00
public List < Models . Tag > Tags
{
2024-02-05 23:08:37 -08:00
get = > _tags ;
private set = > SetProperty ( ref _tags , value ) ;
}
2024-06-27 06:43:15 -07:00
public List < Models . Tag > VisibleTags
{
get = > _visibleTags ;
private set = > SetProperty ( ref _visibleTags , value ) ;
}
2024-08-08 06:11:10 -07:00
public List < Models . Submodule > Submodules
2024-03-17 18:37:06 -07:00
{
2024-02-05 23:08:37 -08:00
get = > _submodules ;
private set = > SetProperty ( ref _submodules , value ) ;
}
2024-08-13 02:38:58 -07:00
public int LocalChangesCount
2024-03-17 18:37:06 -07:00
{
2024-08-13 02:38:58 -07:00
get = > _localChangesCount ;
private set = > SetProperty ( ref _localChangesCount , value ) ;
2024-02-05 23:08:37 -08:00
}
2024-03-17 18:37:06 -07:00
public int StashesCount
{
2024-08-13 02:38:58 -07:00
get = > _stashesCount ;
private set = > SetProperty ( ref _stashesCount , value ) ;
2024-02-05 23:08:37 -08:00
}
2024-03-17 18:37:06 -07:00
public bool IncludeUntracked
{
2024-02-05 23:08:37 -08:00
get = > _includeUntracked ;
2024-03-17 18:37:06 -07:00
set
{
if ( SetProperty ( ref _includeUntracked , value ) )
2024-02-05 23:08:37 -08:00
Task . Run ( RefreshWorkingCopyChanges ) ;
}
}
2024-03-17 18:37:06 -07:00
public bool IsSearching
{
2024-02-05 23:08:37 -08:00
get = > _isSearching ;
2024-03-17 18:37:06 -07:00
set
{
if ( SetProperty ( ref _isSearching , value ) )
{
2024-02-05 23:08:37 -08:00
SearchedCommits = new List < Models . Commit > ( ) ;
SearchCommitFilter = string . Empty ;
2024-07-30 00:59:54 -07:00
SearchCommitFilterSuggestion . Clear ( ) ;
IsSearchCommitSuggestionOpen = false ;
_revisionFiles . Clear ( ) ;
2024-03-31 01:54:29 -07:00
if ( value )
2024-07-30 00:59:54 -07:00
{
2024-03-31 01:54:29 -07:00
SelectedViewIndex = 0 ;
2024-07-30 00:59:54 -07:00
UpdateCurrentRevisionFilesForSearchSuggestion ( ) ;
}
2024-02-05 23:08:37 -08:00
}
}
}
2024-07-09 00:15:31 -07:00
public bool IsSearchLoadingVisible
{
get = > _isSearchLoadingVisible ;
private set = > SetProperty ( ref _isSearchLoadingVisible , value ) ;
}
2024-06-07 03:43:37 -07:00
public int SearchCommitFilterType
{
get = > _searchCommitFilterType ;
2024-07-30 00:59:54 -07:00
set
{
if ( SetProperty ( ref _searchCommitFilterType , value ) )
UpdateCurrentRevisionFilesForSearchSuggestion ( ) ;
}
2024-06-07 03:43:37 -07:00
}
2024-03-17 18:37:06 -07:00
public string SearchCommitFilter
{
2024-02-05 23:08:37 -08:00
get = > _searchCommitFilter ;
2024-07-30 00:59:54 -07:00
set
{
if ( SetProperty ( ref _searchCommitFilter , value ) & &
_searchCommitFilterType = = 3 & &
2024-07-31 01:26:58 -07:00
! string . IsNullOrEmpty ( value ) & &
value . Length > = 2 & &
2024-07-30 00:59:54 -07:00
_revisionFiles . Count > 0 )
{
var suggestion = new List < string > ( ) ;
foreach ( var file in _revisionFiles )
{
if ( file . Contains ( value , StringComparison . OrdinalIgnoreCase ) & & file . Length ! = value . Length )
{
suggestion . Add ( file ) ;
if ( suggestion . Count > 100 )
break ;
}
}
SearchCommitFilterSuggestion . Clear ( ) ;
SearchCommitFilterSuggestion . AddRange ( suggestion ) ;
IsSearchCommitSuggestionOpen = SearchCommitFilterSuggestion . Count > 0 ;
}
else if ( SearchCommitFilterSuggestion . Count > 0 )
{
SearchCommitFilterSuggestion . Clear ( ) ;
IsSearchCommitSuggestionOpen = false ;
}
}
}
public bool IsSearchCommitSuggestionOpen
{
get = > _isSearchCommitSuggestionOpen ;
set = > SetProperty ( ref _isSearchCommitSuggestionOpen , value ) ;
2024-02-05 23:08:37 -08:00
}
2024-07-30 00:59:54 -07:00
public AvaloniaList < string > SearchCommitFilterSuggestion
{
get ;
private set ;
} = new AvaloniaList < string > ( ) ;
2024-03-17 18:37:06 -07:00
public List < Models . Commit > SearchedCommits
{
2024-02-05 23:08:37 -08:00
get = > _searchedCommits ;
set = > SetProperty ( ref _searchedCommits , value ) ;
}
2024-07-04 02:59:32 -07:00
public bool IsLocalBranchGroupExpanded
{
get = > _isLocalBranchGroupExpanded ;
set = > SetProperty ( ref _isLocalBranchGroupExpanded , value ) ;
}
public bool IsRemoteGroupExpanded
{
get = > _isRemoteGroupExpanded ;
set = > SetProperty ( ref _isRemoteGroupExpanded , value ) ;
}
2024-03-20 20:40:17 -07:00
public bool IsTagGroupExpanded
{
get = > _isTagGroupExpanded ;
set = > SetProperty ( ref _isTagGroupExpanded , value ) ;
}
public bool IsSubmoduleGroupExpanded
{
get = > _isSubmoduleGroupExpanded ;
set = > SetProperty ( ref _isSubmoduleGroupExpanded , value ) ;
}
2024-06-27 03:25:16 -07:00
public bool IsWorktreeGroupExpanded
{
get = > _isWorktreeGroupExpanded ;
set = > SetProperty ( ref _isWorktreeGroupExpanded , value ) ;
}
2024-04-01 06:27:08 -07:00
public InProgressContext InProgressContext
{
get = > _inProgressContext ;
private set = > SetProperty ( ref _inProgressContext , value ) ;
}
public bool HasUnsolvedConflicts
{
get = > _hasUnsolvedConflicts ;
private set = > SetProperty ( ref _hasUnsolvedConflicts , value ) ;
}
2024-05-10 01:04:03 -07:00
public Models . Commit SearchResultSelectedCommit
{
get = > _searchResultSelectedCommit ;
2024-08-27 06:28:48 -07:00
set
{
if ( SetProperty ( ref _searchResultSelectedCommit , value ) & & value ! = null )
NavigateToCommit ( value . SHA ) ;
}
2024-05-10 01:04:03 -07:00
}
2024-03-17 18:37:06 -07:00
public void Open ( )
{
2024-06-30 20:57:13 -07:00
var settingsFile = Path . Combine ( _gitDir , "sourcegit.settings" ) ;
2024-07-01 23:17:21 -07:00
if ( File . Exists ( settingsFile ) )
2024-06-30 20:57:13 -07:00
{
2024-07-01 23:17:21 -07:00
try
{
_settings = JsonSerializer . Deserialize ( File . ReadAllText ( settingsFile ) , JsonCodeGen . Default . RepositorySettings ) ;
}
catch
{
2024-07-22 23:52:25 -07:00
_settings = new Models . RepositorySettings ( ) ;
2024-07-01 23:17:21 -07:00
}
2024-06-30 20:57:13 -07:00
}
2024-07-01 23:17:21 -07:00
else
2024-06-30 20:57:13 -07:00
{
2024-07-22 23:52:25 -07:00
_settings = new Models . RepositorySettings ( ) ;
2024-06-30 20:57:13 -07:00
}
2024-08-26 02:50:13 -07:00
try
{
_watcher = new Models . Watcher ( this ) ;
}
catch ( Exception ex )
{
App . RaiseException ( string . Empty , $"Failed to start watcher for repository: '{_fullpath}'. You may need to press 'F5' to refresh repository manually!\n\nReason: {ex.Message}" ) ;
}
2024-02-05 23:08:37 -08:00
_histories = new Histories ( this ) ;
_workingCopy = new WorkingCopy ( this ) ;
_stashesPage = new StashesPage ( this ) ;
_selectedView = _histories ;
_selectedViewIndex = 0 ;
2024-04-01 06:27:08 -07:00
_inProgressContext = null ;
_hasUnsolvedConflicts = false ;
2024-02-05 23:08:37 -08:00
2024-04-27 19:19:12 -07:00
RefreshAll ( ) ;
2024-02-05 23:08:37 -08:00
}
2024-03-17 18:37:06 -07:00
public void Close ( )
{
2024-07-25 00:31:16 -07:00
SelectedView = null ; // Do NOT modify. Used to remove exists widgets for GC.Collect
2024-02-20 02:27:59 -08:00
2024-06-30 20:57:13 -07:00
var settingsSerialized = JsonSerializer . Serialize ( _settings , JsonCodeGen . Default . RepositorySettings ) ;
2024-08-26 19:42:56 -07:00
try
{
File . WriteAllText ( Path . Combine ( _gitDir , "sourcegit.settings" ) , settingsSerialized ) ;
}
catch ( DirectoryNotFoundException )
{
// Ignore
}
2024-06-30 20:57:13 -07:00
_settings = null ;
2024-08-26 02:50:13 -07:00
_watcher ? . Dispose ( ) ;
2024-02-20 02:27:59 -08:00
_histories . Cleanup ( ) ;
_workingCopy . Cleanup ( ) ;
_stashesPage . Cleanup ( ) ;
2024-02-05 23:08:37 -08:00
_watcher = null ;
_histories = null ;
_workingCopy = null ;
_stashesPage = null ;
2024-04-01 06:27:08 -07:00
_inProgressContext = null ;
2024-08-13 02:38:58 -07:00
_localChangesCount = 0 ;
_stashesCount = 0 ;
2024-02-05 23:08:37 -08:00
_remotes . Clear ( ) ;
_branches . Clear ( ) ;
_localBranchTrees . Clear ( ) ;
_remoteBranchTrees . Clear ( ) ;
_tags . Clear ( ) ;
2024-06-27 06:43:15 -07:00
_visibleTags . Clear ( ) ;
2024-02-05 23:08:37 -08:00
_submodules . Clear ( ) ;
_searchedCommits . Clear ( ) ;
2024-07-30 00:59:54 -07:00
_revisionFiles . Clear ( ) ;
SearchCommitFilterSuggestion . Clear ( ) ;
2024-02-05 23:08:37 -08:00
}
2024-04-27 19:19:12 -07:00
public void RefreshAll ( )
{
Task . Run ( ( ) = >
{
RefreshBranches ( ) ;
RefreshTags ( ) ;
RefreshCommits ( ) ;
} ) ;
Task . Run ( RefreshSubmodules ) ;
2024-06-27 03:25:16 -07:00
Task . Run ( RefreshWorktrees ) ;
2024-04-27 19:19:12 -07:00
Task . Run ( RefreshWorkingCopyChanges ) ;
Task . Run ( RefreshStashes ) ;
}
2024-03-17 18:37:06 -07:00
public void OpenInFileManager ( )
{
2024-02-05 23:08:37 -08:00
Native . OS . OpenInFileManager ( _fullpath ) ;
}
2024-04-05 22:14:22 -07:00
public void OpenInTerminal ( )
2024-03-17 18:37:06 -07:00
{
2024-04-05 22:14:22 -07:00
Native . OS . OpenTerminal ( _fullpath ) ;
2024-02-05 23:08:37 -08:00
}
2024-03-28 02:42:13 -07:00
2024-04-08 02:39:52 -07:00
public ContextMenu CreateContextMenuForExternalTools ( )
2024-03-27 22:49:32 -07:00
{
2024-04-08 02:39:52 -07:00
var tools = Native . OS . ExternalTools ;
if ( tools . Count = = 0 )
2024-04-05 22:14:22 -07:00
{
App . RaiseException ( _fullpath , "No available external editors found!" ) ;
return null ;
}
2024-02-05 23:08:37 -08:00
2024-04-05 22:14:22 -07:00
var menu = new ContextMenu ( ) ;
menu . Placement = PlacementMode . BottomEdgeAlignedLeft ;
RenderOptions . SetBitmapInterpolationMode ( menu , BitmapInterpolationMode . HighQuality ) ;
2024-04-08 02:39:52 -07:00
foreach ( var tool in tools )
2024-04-05 22:14:22 -07:00
{
2024-04-08 02:39:52 -07:00
var dupTool = tool ;
2024-04-09 00:00:52 -07:00
2024-04-05 22:14:22 -07:00
var item = new MenuItem ( ) ;
2024-04-08 02:39:52 -07:00
item . Header = App . Text ( "Repository.OpenIn" , dupTool . Name ) ;
2024-04-09 00:00:52 -07:00
item . Icon = new Image { Width = 16 , Height = 16 , Source = dupTool . IconImage } ;
2024-07-14 09:30:31 -07:00
item . Click + = ( _ , e ) = >
2024-04-05 22:14:22 -07:00
{
2024-04-08 02:39:52 -07:00
dupTool . Open ( _fullpath ) ;
2024-04-05 22:14:22 -07:00
e . Handled = true ;
} ;
menu . Items . Add ( item ) ;
}
return menu ;
2024-02-05 23:08:37 -08:00
}
2024-08-12 00:01:00 -07:00
public void Fetch ( bool autoStart )
2024-03-17 18:37:06 -07:00
{
2024-03-31 01:54:29 -07:00
if ( ! PopupHost . CanCreatePopup ( ) )
return ;
2024-02-05 23:08:37 -08:00
2024-07-24 00:36:26 -07:00
if ( _remotes . Count = = 0 )
2024-03-17 18:37:06 -07:00
{
2024-02-05 23:08:37 -08:00
App . RaiseException ( _fullpath , "No remotes added to this repository!!!" ) ;
return ;
}
2024-08-12 00:01:00 -07:00
if ( autoStart )
PopupHost . ShowAndStartPopup ( new Fetch ( this ) ) ;
else
PopupHost . ShowPopup ( new Fetch ( this ) ) ;
2024-02-05 23:08:37 -08:00
}
2024-08-12 00:01:00 -07:00
public void Pull ( bool autoStart )
2024-03-17 18:37:06 -07:00
{
2024-03-31 01:54:29 -07:00
if ( ! PopupHost . CanCreatePopup ( ) )
return ;
2024-02-05 23:08:37 -08:00
2024-07-24 00:36:26 -07:00
if ( _remotes . Count = = 0 )
2024-03-17 18:37:06 -07:00
{
2024-02-05 23:08:37 -08:00
App . RaiseException ( _fullpath , "No remotes added to this repository!!!" ) ;
return ;
}
2024-08-12 00:01:00 -07:00
if ( autoStart )
PopupHost . ShowAndStartPopup ( new Pull ( this , null ) ) ;
else
PopupHost . ShowPopup ( new Pull ( this , null ) ) ;
2024-02-05 23:08:37 -08:00
}
2024-08-12 00:01:00 -07:00
public void Push ( bool autoStart )
2024-03-17 18:37:06 -07:00
{
2024-03-31 01:54:29 -07:00
if ( ! PopupHost . CanCreatePopup ( ) )
return ;
2024-02-05 23:08:37 -08:00
2024-07-24 00:36:26 -07:00
if ( _remotes . Count = = 0 )
2024-03-17 18:37:06 -07:00
{
2024-02-05 23:08:37 -08:00
App . RaiseException ( _fullpath , "No remotes added to this repository!!!" ) ;
return ;
}
2024-07-24 00:36:26 -07:00
if ( _currentBranch = = null )
2024-05-29 06:31:46 -07:00
{
2024-03-31 01:54:29 -07:00
App . RaiseException ( _fullpath , "Can NOT found current branch!!!" ) ;
2024-05-29 06:31:46 -07:00
return ;
}
2024-05-29 18:53:07 -07:00
2024-08-12 00:01:00 -07:00
if ( autoStart )
PopupHost . ShowAndStartPopup ( new Push ( this , null ) ) ;
else
PopupHost . ShowPopup ( new Push ( this , null ) ) ;
2024-02-05 23:08:37 -08:00
}
2024-03-17 18:37:06 -07:00
public void ApplyPatch ( )
{
2024-03-31 01:54:29 -07:00
if ( ! PopupHost . CanCreatePopup ( ) )
return ;
2024-02-05 23:08:37 -08:00
PopupHost . ShowPopup ( new Apply ( this ) ) ;
}
2024-03-17 18:37:06 -07:00
public void Cleanup ( )
{
2024-03-31 01:54:29 -07:00
if ( ! PopupHost . CanCreatePopup ( ) )
return ;
2024-02-05 23:08:37 -08:00
PopupHost . ShowAndStartPopup ( new Cleanup ( this ) ) ;
}
2024-06-18 03:27:57 -07:00
public void ClearHistoriesFilter ( )
{
2024-06-30 20:57:13 -07:00
_settings . Filters . Clear ( ) ;
2024-06-18 03:27:57 -07:00
Task . Run ( ( ) = >
{
RefreshBranches ( ) ;
RefreshTags ( ) ;
RefreshCommits ( ) ;
} ) ;
}
2024-03-17 18:37:06 -07:00
public void ClearSearchCommitFilter ( )
{
2024-02-05 23:08:37 -08:00
SearchCommitFilter = string . Empty ;
}
2024-03-17 18:37:06 -07:00
public void StartSearchCommits ( )
{
2024-03-31 01:54:29 -07:00
if ( _histories = = null )
return ;
2024-02-05 23:08:37 -08:00
2024-07-09 00:15:31 -07:00
IsSearchLoadingVisible = true ;
2024-08-28 01:56:43 -07:00
SearchResultSelectedCommit = null ;
2024-07-30 00:59:54 -07:00
IsSearchCommitSuggestionOpen = false ;
SearchCommitFilterSuggestion . Clear ( ) ;
2024-06-07 03:43:37 -07:00
2024-07-09 00:15:31 -07:00
Task . Run ( ( ) = >
2024-06-07 03:43:37 -07:00
{
2024-07-09 00:15:31 -07:00
var visible = new List < Models . Commit > ( ) ;
2024-07-13 07:36:59 -07:00
switch ( _searchCommitFilterType )
2024-03-17 18:37:06 -07:00
{
2024-07-13 07:36:59 -07:00
case 0 :
2024-08-28 01:56:43 -07:00
var commit = new Commands . QuerySingleCommit ( _fullpath , _searchCommitFilter ) . Result ( ) ;
if ( commit ! = null )
visible . Add ( commit ) ;
2024-07-13 07:36:59 -07:00
break ;
case 1 :
2024-08-28 01:56:43 -07:00
visible = new Commands . QueryCommits ( _fullpath , _searchCommitFilter , Models . CommitSearchMethod . ByUser ) . Result ( ) ;
2024-07-13 07:36:59 -07:00
break ;
case 2 :
2024-08-28 01:56:43 -07:00
visible = new Commands . QueryCommits ( _fullpath , _searchCommitFilter , Models . CommitSearchMethod . ByMessage ) . Result ( ) ;
2024-07-13 07:36:59 -07:00
break ;
case 3 :
2024-08-28 01:56:43 -07:00
visible = new Commands . QueryCommits ( _fullpath , _searchCommitFilter , Models . CommitSearchMethod . ByFile ) . Result ( ) ;
2024-07-13 07:36:59 -07:00
break ;
2024-07-09 00:15:31 -07:00
}
2024-02-05 23:08:37 -08:00
2024-07-09 00:15:31 -07:00
Dispatcher . UIThread . Invoke ( ( ) = >
{
SearchedCommits = visible ;
IsSearchLoadingVisible = false ;
} ) ;
} ) ;
2024-02-05 23:08:37 -08:00
}
2024-05-13 20:47:56 -07:00
public void ClearSearchBranchFilter ( )
{
SearchBranchFilter = string . Empty ;
}
2024-03-17 18:37:06 -07:00
public void SetWatcherEnabled ( bool enabled )
{
2024-08-26 02:50:13 -07:00
_watcher ? . SetEnabled ( enabled ) ;
2024-02-05 23:08:37 -08:00
}
2024-03-17 18:37:06 -07:00
public void MarkBranchesDirtyManually ( )
{
2024-08-26 02:50:13 -07:00
if ( _watcher = = null )
{
Task . Run ( ( ) = >
{
RefreshBranches ( ) ;
RefreshCommits ( ) ;
} ) ;
Task . Run ( RefreshWorkingCopyChanges ) ;
Task . Run ( RefreshWorktrees ) ;
2024-08-27 22:42:25 -07:00
}
2024-08-26 02:50:13 -07:00
else
{
2024-03-31 01:54:29 -07:00
_watcher . MarkBranchDirtyManually ( ) ;
2024-08-26 02:50:13 -07:00
}
2024-03-07 17:57:29 -08:00
}
2024-03-17 18:37:06 -07:00
public void MarkWorkingCopyDirtyManually ( )
{
2024-08-26 02:50:13 -07:00
if ( _watcher = = null )
Task . Run ( RefreshWorkingCopyChanges ) ;
else
2024-03-31 01:54:29 -07:00
_watcher . MarkWorkingCopyDirtyManually ( ) ;
2024-03-07 17:57:29 -08:00
}
2024-03-17 18:37:06 -07:00
public void NavigateToCommit ( string sha )
{
if ( _histories ! = null )
{
2024-02-05 23:08:37 -08:00
SelectedViewIndex = 0 ;
_histories . NavigateTo ( sha ) ;
}
}
2024-04-02 05:54:19 -07:00
public void NavigateToCurrentHead ( )
{
2024-07-24 00:36:26 -07:00
if ( _currentBranch ! = null )
NavigateToCommit ( _currentBranch . Head ) ;
2024-04-02 05:54:19 -07:00
}
2024-03-17 18:37:06 -07:00
public void UpdateFilter ( string filter , bool toggle )
{
2024-02-05 23:08:37 -08:00
var changed = false ;
2024-03-17 18:37:06 -07:00
if ( toggle )
{
2024-06-30 20:57:13 -07:00
if ( ! _settings . Filters . Contains ( filter ) )
2024-03-17 18:37:06 -07:00
{
2024-06-30 20:57:13 -07:00
_settings . Filters . Add ( filter ) ;
2024-02-05 23:08:37 -08:00
changed = true ;
}
2024-03-17 18:37:06 -07:00
}
else
{
2024-06-30 20:57:13 -07:00
changed = _settings . Filters . Remove ( filter ) ;
2024-02-05 23:08:37 -08:00
}
2024-03-31 01:54:29 -07:00
if ( changed )
Task . Run ( RefreshCommits ) ;
2024-02-05 23:08:37 -08:00
}
2024-08-12 00:11:49 -07:00
public void StashAll ( bool autoStart )
2024-03-17 18:37:06 -07:00
{
2024-08-12 00:11:49 -07:00
_workingCopy ? . StashAll ( autoStart ) ;
2024-02-05 23:08:37 -08:00
}
2024-03-17 18:37:06 -07:00
public void GotoResolve ( )
{
2024-03-31 01:54:29 -07:00
if ( _workingCopy ! = null )
SelectedViewIndex = 1 ;
2024-02-05 23:08:37 -08:00
}
2024-03-17 18:37:06 -07:00
public async void ContinueMerge ( )
{
2024-04-01 06:27:08 -07:00
if ( _inProgressContext ! = null )
2024-03-17 18:37:06 -07:00
{
2024-04-01 06:27:08 -07:00
SetWatcherEnabled ( false ) ;
var succ = await Task . Run ( _inProgressContext . Continue ) ;
if ( succ & & _workingCopy ! = null )
{
_workingCopy . CommitMessage = string . Empty ;
}
SetWatcherEnabled ( true ) ;
2024-03-17 18:37:06 -07:00
}
else
{
2024-03-07 17:57:29 -08:00
MarkWorkingCopyDirtyManually ( ) ;
2024-02-05 23:08:37 -08:00
}
}
2024-03-17 18:37:06 -07:00
public async void AbortMerge ( )
{
2024-04-01 06:27:08 -07:00
if ( _inProgressContext ! = null )
2024-03-17 18:37:06 -07:00
{
2024-04-01 06:27:08 -07:00
SetWatcherEnabled ( false ) ;
2024-04-28 18:30:37 -07:00
var succ = await Task . Run ( _inProgressContext . Abort ) ;
if ( succ & & _workingCopy ! = null )
{
_workingCopy . CommitMessage = string . Empty ;
}
2024-04-01 06:27:08 -07:00
SetWatcherEnabled ( true ) ;
2024-03-17 18:37:06 -07:00
}
else
{
2024-03-07 17:57:29 -08:00
MarkWorkingCopyDirtyManually ( ) ;
2024-02-05 23:08:37 -08:00
}
}
2024-03-17 18:37:06 -07:00
public void RefreshBranches ( )
{
2024-07-24 00:36:26 -07:00
var branches = new Commands . QueryBranches ( _fullpath ) . Result ( ) ;
var remotes = new Commands . QueryRemotes ( _fullpath ) . Result ( ) ;
2024-05-13 20:47:56 -07:00
var builder = BuildBranchTree ( branches , remotes ) ;
2024-02-05 23:08:37 -08:00
2024-03-17 18:37:06 -07:00
Dispatcher . UIThread . Invoke ( ( ) = >
{
2024-02-05 23:08:37 -08:00
Remotes = remotes ;
Branches = branches ;
2024-07-24 00:36:26 -07:00
CurrentBranch = branches . Find ( x = > x . IsCurrent ) ;
2024-02-05 23:08:37 -08:00
LocalBranchTrees = builder . Locals ;
RemoteBranchTrees = builder . Remotes ;
2024-05-30 00:13:59 -07:00
if ( _workingCopy ! = null )
2024-07-24 00:36:26 -07:00
_workingCopy . CanCommitWithPush = _currentBranch ! = null & & ! string . IsNullOrEmpty ( _currentBranch . Upstream ) ;
2024-02-05 23:08:37 -08:00
} ) ;
}
2024-06-27 03:25:16 -07:00
public void RefreshWorktrees ( )
{
var worktrees = new Commands . Worktree ( _fullpath ) . List ( ) ;
var cleaned = new List < Models . Worktree > ( ) ;
foreach ( var worktree in worktrees )
{
if ( worktree . IsBare | | worktree . FullPath . Equals ( _fullpath ) )
continue ;
cleaned . Add ( worktree ) ;
}
Dispatcher . UIThread . Invoke ( ( ) = >
{
Worktrees = cleaned ;
} ) ;
}
2024-03-17 18:37:06 -07:00
public void RefreshTags ( )
{
2024-07-24 00:36:26 -07:00
var tags = new Commands . QueryTags ( _fullpath ) . Result ( ) ;
2024-03-31 01:54:29 -07:00
foreach ( var tag in tags )
2024-06-30 20:57:13 -07:00
tag . IsFiltered = _settings . Filters . Contains ( tag . Name ) ;
2024-06-27 03:25:16 -07:00
2024-03-17 18:37:06 -07:00
Dispatcher . UIThread . Invoke ( ( ) = >
{
2024-02-05 23:08:37 -08:00
Tags = tags ;
2024-06-27 06:43:15 -07:00
VisibleTags = BuildVisibleTags ( ) ;
2024-02-05 23:08:37 -08:00
} ) ;
}
2024-03-17 18:37:06 -07:00
public void RefreshCommits ( )
{
2024-02-05 23:08:37 -08:00
Dispatcher . UIThread . Invoke ( ( ) = > _histories . IsLoading = true ) ;
var limits = $"-{Preference.Instance.MaxHistoryCommits} " ;
2024-08-21 04:45:32 -07:00
if ( _enableFirstParentInHistories )
limits + = "--first-parent " ;
2024-02-05 23:08:37 -08:00
var validFilters = new List < string > ( ) ;
2024-06-30 20:57:13 -07:00
foreach ( var filter in _settings . Filters )
2024-03-17 18:37:06 -07:00
{
if ( filter . StartsWith ( "refs/" , StringComparison . Ordinal ) )
{
2024-03-31 01:54:29 -07:00
if ( _branches . FindIndex ( x = > x . FullName = = filter ) > = 0 )
validFilters . Add ( filter ) ;
2024-03-17 18:37:06 -07:00
}
else
{
2024-03-31 01:54:29 -07:00
if ( _tags . FindIndex ( t = > t . Name = = filter ) > = 0 )
validFilters . Add ( filter ) ;
2024-02-05 23:08:37 -08:00
}
}
2024-06-18 03:27:57 -07:00
2024-03-17 18:37:06 -07:00
if ( validFilters . Count > 0 )
{
2024-02-05 23:08:37 -08:00
limits + = string . Join ( " " , validFilters ) ;
2024-06-18 03:27:57 -07:00
2024-06-30 20:57:13 -07:00
if ( _settings . Filters . Count ! = validFilters . Count )
2024-06-18 03:27:57 -07:00
{
Dispatcher . UIThread . Post ( ( ) = >
{
2024-06-30 20:57:13 -07:00
_settings . Filters . Clear ( ) ;
_settings . Filters . AddRange ( validFilters ) ;
2024-06-18 03:27:57 -07:00
} ) ;
}
2024-03-17 18:37:06 -07:00
}
else
{
2024-08-21 04:45:32 -07:00
limits + = "--exclude=refs/stash --all" ;
2024-02-05 23:08:37 -08:00
}
2024-07-18 18:29:16 -07:00
var commits = new Commands . QueryCommits ( _fullpath , limits ) . Result ( ) ;
2024-08-21 04:45:32 -07:00
var graph = Models . CommitGraph . Parse ( commits , _enableFirstParentInHistories ) ;
2024-06-06 05:25:16 -07:00
2024-03-17 18:37:06 -07:00
Dispatcher . UIThread . Invoke ( ( ) = >
{
if ( _histories ! = null )
{
2024-02-20 20:26:09 -08:00
_histories . IsLoading = false ;
_histories . Commits = commits ;
2024-06-06 05:25:16 -07:00
_histories . Graph = graph ;
2024-03-17 18:37:06 -07:00
}
2024-02-05 23:08:37 -08:00
} ) ;
}
2024-03-17 18:37:06 -07:00
public void RefreshSubmodules ( )
{
2024-07-24 00:36:26 -07:00
var submodules = new Commands . QuerySubmodules ( _fullpath ) . Result ( ) ;
2024-08-26 02:50:13 -07:00
_watcher ? . SetSubmodules ( submodules ) ;
2024-06-27 03:25:16 -07:00
Dispatcher . UIThread . Invoke ( ( ) = > Submodules = submodules ) ;
2024-02-05 23:08:37 -08:00
}
2024-03-17 18:37:06 -07:00
public void RefreshWorkingCopyChanges ( )
{
2024-07-24 00:36:26 -07:00
var changes = new Commands . QueryLocalChanges ( _fullpath , _includeUntracked ) . Result ( ) ;
2024-04-02 01:23:47 -07:00
if ( _workingCopy = = null )
return ;
2024-02-05 23:08:37 -08:00
var hasUnsolvedConflict = _workingCopy . SetData ( changes ) ;
2024-04-01 06:27:08 -07:00
var inProgress = null as InProgressContext ;
2024-02-05 23:08:37 -08:00
var rebaseMergeFolder = Path . Combine ( _gitDir , "rebase-merge" ) ;
2024-04-01 06:27:08 -07:00
var rebaseApplyFolder = Path . Combine ( _gitDir , "rebase-apply" ) ;
if ( File . Exists ( Path . Combine ( _gitDir , "CHERRY_PICK_HEAD" ) ) )
{
inProgress = new CherryPickInProgress ( _fullpath ) ;
}
else if ( File . Exists ( Path . Combine ( _gitDir , "REBASE_HEAD" ) ) & & Directory . Exists ( rebaseMergeFolder ) )
{
inProgress = new RebaseInProgress ( this ) ;
}
else if ( File . Exists ( Path . Combine ( _gitDir , "REVERT_HEAD" ) ) )
{
inProgress = new RevertInProgress ( _fullpath ) ;
}
else if ( File . Exists ( Path . Combine ( _gitDir , "MERGE_HEAD" ) ) )
{
inProgress = new MergeInProgress ( _fullpath ) ;
}
else
2024-03-17 18:37:06 -07:00
{
2024-03-31 01:54:29 -07:00
if ( Directory . Exists ( rebaseMergeFolder ) )
Directory . Delete ( rebaseMergeFolder , true ) ;
2024-04-01 06:27:08 -07:00
if ( Directory . Exists ( rebaseApplyFolder ) )
Directory . Delete ( rebaseApplyFolder , true ) ;
2024-02-05 23:08:37 -08:00
}
2024-03-17 18:37:06 -07:00
Dispatcher . UIThread . Invoke ( ( ) = >
{
2024-04-01 06:27:08 -07:00
InProgressContext = inProgress ;
HasUnsolvedConflicts = hasUnsolvedConflict ;
2024-08-13 02:38:58 -07:00
LocalChangesCount = changes . Count ;
2024-02-05 23:08:37 -08:00
} ) ;
}
2024-03-17 18:37:06 -07:00
public void RefreshStashes ( )
{
2024-07-24 00:36:26 -07:00
var stashes = new Commands . QueryStashes ( _fullpath ) . Result ( ) ;
2024-03-17 18:37:06 -07:00
Dispatcher . UIThread . Invoke ( ( ) = >
{
2024-03-31 01:54:29 -07:00
if ( _stashesPage ! = null )
_stashesPage . Stashes = stashes ;
2024-08-13 02:38:58 -07:00
StashesCount = stashes . Count ;
2024-02-05 23:08:37 -08:00
} ) ;
}
2024-03-17 18:37:06 -07:00
public void CreateNewBranch ( )
{
2024-07-24 00:36:26 -07:00
if ( _currentBranch = = null )
2024-03-17 18:37:06 -07:00
{
2024-02-05 23:08:37 -08:00
App . RaiseException ( _fullpath , "Git do not hold any branch until you do first commit." ) ;
return ;
}
2024-03-31 01:54:29 -07:00
if ( PopupHost . CanCreatePopup ( ) )
2024-07-24 00:36:26 -07:00
PopupHost . ShowPopup ( new CreateBranch ( this , _currentBranch ) ) ;
2024-02-05 23:08:37 -08:00
}
2024-05-29 01:42:47 -07:00
public void CheckoutBranch ( Models . Branch branch )
2024-04-29 02:22:22 -07:00
{
2024-06-27 03:25:16 -07:00
if ( branch . IsLocal )
{
var worktree = _worktrees . Find ( x = > x . Branch = = branch . FullName ) ;
if ( worktree ! = null )
{
OpenWorktree ( worktree ) ;
return ;
}
}
2024-04-29 02:22:22 -07:00
if ( ! PopupHost . CanCreatePopup ( ) )
return ;
2024-05-29 01:42:47 -07:00
if ( branch . IsLocal )
{
2024-08-13 02:38:58 -07:00
if ( _localChangesCount > 0 )
2024-05-29 01:42:47 -07:00
PopupHost . ShowPopup ( new Checkout ( this , branch . Name ) ) ;
else
PopupHost . ShowAndStartPopup ( new Checkout ( this , branch . Name ) ) ;
}
2024-04-29 02:22:22 -07:00
else
2024-05-29 01:42:47 -07:00
{
2024-07-24 00:36:26 -07:00
foreach ( var b in _branches )
2024-05-29 01:42:47 -07:00
{
if ( b . IsLocal & & b . Upstream = = branch . FullName )
{
if ( ! b . IsCurrent )
CheckoutBranch ( b ) ;
return ;
}
}
PopupHost . ShowPopup ( new CreateBranch ( this , branch ) ) ;
}
2024-04-29 02:22:22 -07:00
}
2024-05-29 01:42:47 -07:00
2024-05-24 04:15:12 -07:00
public void DeleteMultipleBranches ( List < Models . Branch > branches , bool isLocal )
{
if ( PopupHost . CanCreatePopup ( ) )
PopupHost . ShowPopup ( new DeleteMultipleBranches ( this , branches , isLocal ) ) ;
}
2024-03-17 18:37:06 -07:00
public void CreateNewTag ( )
{
2024-07-24 00:36:26 -07:00
if ( _currentBranch = = null )
2024-03-17 18:37:06 -07:00
{
2024-02-05 23:08:37 -08:00
App . RaiseException ( _fullpath , "Git do not hold any branch until you do first commit." ) ;
return ;
}
2024-03-31 01:54:29 -07:00
if ( PopupHost . CanCreatePopup ( ) )
2024-07-24 00:36:26 -07:00
PopupHost . ShowPopup ( new CreateTag ( this , _currentBranch ) ) ;
2024-02-05 23:08:37 -08:00
}
2024-03-17 18:37:06 -07:00
public void AddRemote ( )
{
2024-03-31 01:54:29 -07:00
if ( PopupHost . CanCreatePopup ( ) )
PopupHost . ShowPopup ( new AddRemote ( this ) ) ;
2024-02-05 23:08:37 -08:00
}
2024-03-17 18:37:06 -07:00
public void AddSubmodule ( )
{
2024-03-31 01:54:29 -07:00
if ( PopupHost . CanCreatePopup ( ) )
PopupHost . ShowPopup ( new AddSubmodule ( this ) ) ;
2024-02-05 23:08:37 -08:00
}
2024-06-03 20:36:00 -07:00
public void UpdateSubmodules ( )
{
if ( PopupHost . CanCreatePopup ( ) )
2024-07-26 03:49:07 -07:00
PopupHost . ShowPopup ( new UpdateSubmodules ( this ) ) ;
2024-06-03 20:36:00 -07:00
}
2024-06-26 00:51:49 -07:00
public void OpenSubmodule ( string submodule )
{
var root = Path . GetFullPath ( Path . Combine ( _fullpath , submodule ) ) ;
2024-06-30 20:57:13 -07:00
var normalizedPath = root . Replace ( "\\" , "/" ) ;
2024-06-26 00:51:49 -07:00
2024-07-22 00:34:31 -07:00
var node = Preference . Instance . FindNode ( normalizedPath ) ;
2024-06-30 20:57:13 -07:00
if ( node = = null )
2024-06-26 00:51:49 -07:00
{
2024-06-30 20:57:13 -07:00
node = new RepositoryNode ( )
{
Id = normalizedPath ,
Name = Path . GetFileName ( normalizedPath ) ,
Bookmark = 0 ,
IsRepository = true ,
} ;
}
2024-06-26 00:51:49 -07:00
2024-08-18 21:49:04 -07:00
App . GetLauncer ( ) ? . OpenRepositoryInTab ( node , null ) ;
2024-06-26 00:51:49 -07:00
}
2024-06-27 03:25:16 -07:00
public void AddWorktree ( )
{
if ( PopupHost . CanCreatePopup ( ) )
PopupHost . ShowPopup ( new AddWorktree ( this ) ) ;
}
public void PruneWorktrees ( )
{
if ( PopupHost . CanCreatePopup ( ) )
PopupHost . ShowAndStartPopup ( new PruneWorktrees ( this ) ) ;
}
public void OpenWorktree ( Models . Worktree worktree )
{
2024-07-22 00:34:31 -07:00
var node = Preference . Instance . FindNode ( worktree . FullPath ) ;
2024-06-30 20:57:13 -07:00
if ( node = = null )
2024-06-27 03:25:16 -07:00
{
2024-06-30 20:57:13 -07:00
node = new RepositoryNode ( )
{
Id = worktree . FullPath ,
Name = Path . GetFileName ( worktree . FullPath ) ,
Bookmark = 0 ,
IsRepository = true ,
} ;
}
2024-06-27 03:25:16 -07:00
2024-08-18 21:49:04 -07:00
App . GetLauncer ( ) ? . OpenRepositoryInTab ( node , null ) ;
2024-06-27 03:25:16 -07:00
}
2024-03-17 18:37:06 -07:00
public ContextMenu CreateContextMenuForGitFlow ( )
{
2024-02-05 23:08:37 -08:00
var menu = new ContextMenu ( ) ;
menu . Placement = PlacementMode . BottomEdgeAlignedLeft ;
2024-06-14 21:44:35 -07:00
var isGitFlowEnabled = Commands . GitFlow . IsEnabled ( _fullpath , _branches ) ;
if ( isGitFlowEnabled )
2024-03-17 18:37:06 -07:00
{
2024-02-05 23:08:37 -08:00
var startFeature = new MenuItem ( ) ;
startFeature . Header = App . Text ( "GitFlow.StartFeature" ) ;
2024-04-15 00:07:07 -07:00
startFeature . Icon = App . CreateMenuIcon ( "Icons.GitFlow.Feature" ) ;
2024-07-14 09:30:31 -07:00
startFeature . Click + = ( _ , e ) = >
2024-03-17 18:37:06 -07:00
{
2024-03-31 01:54:29 -07:00
if ( PopupHost . CanCreatePopup ( ) )
2024-06-14 21:44:35 -07:00
PopupHost . ShowPopup ( new GitFlowStart ( this , "feature" ) ) ;
2024-02-05 23:08:37 -08:00
e . Handled = true ;
} ;
var startRelease = new MenuItem ( ) ;
startRelease . Header = App . Text ( "GitFlow.StartRelease" ) ;
2024-04-15 00:07:07 -07:00
startRelease . Icon = App . CreateMenuIcon ( "Icons.GitFlow.Release" ) ;
2024-07-14 09:30:31 -07:00
startRelease . Click + = ( _ , e ) = >
2024-03-17 18:37:06 -07:00
{
2024-03-31 01:54:29 -07:00
if ( PopupHost . CanCreatePopup ( ) )
2024-06-14 21:44:35 -07:00
PopupHost . ShowPopup ( new GitFlowStart ( this , "release" ) ) ;
2024-02-05 23:08:37 -08:00
e . Handled = true ;
} ;
var startHotfix = new MenuItem ( ) ;
startHotfix . Header = App . Text ( "GitFlow.StartHotfix" ) ;
2024-04-15 00:07:07 -07:00
startHotfix . Icon = App . CreateMenuIcon ( "Icons.GitFlow.Hotfix" ) ;
2024-07-14 09:30:31 -07:00
startHotfix . Click + = ( _ , e ) = >
2024-03-17 18:37:06 -07:00
{
2024-03-31 01:54:29 -07:00
if ( PopupHost . CanCreatePopup ( ) )
2024-06-14 21:44:35 -07:00
PopupHost . ShowPopup ( new GitFlowStart ( this , "hotfix" ) ) ;
2024-02-05 23:08:37 -08:00
e . Handled = true ;
} ;
menu . Items . Add ( startFeature ) ;
menu . Items . Add ( startRelease ) ;
menu . Items . Add ( startHotfix ) ;
2024-03-17 18:37:06 -07:00
}
else
{
2024-02-05 23:08:37 -08:00
var init = new MenuItem ( ) ;
init . Header = App . Text ( "GitFlow.Init" ) ;
2024-06-17 03:25:57 -07:00
init . Icon = App . CreateMenuIcon ( "Icons.Init" ) ;
2024-07-14 09:30:31 -07:00
init . Click + = ( _ , e ) = >
2024-03-17 18:37:06 -07:00
{
2024-03-31 01:54:29 -07:00
if ( PopupHost . CanCreatePopup ( ) )
PopupHost . ShowPopup ( new InitGitFlow ( this ) ) ;
2024-02-05 23:08:37 -08:00
e . Handled = true ;
} ;
menu . Items . Add ( init ) ;
}
return menu ;
2024-06-17 03:25:57 -07:00
}
public ContextMenu CreateContextMenuForGitLFS ( )
{
var menu = new ContextMenu ( ) ;
menu . Placement = PlacementMode . BottomEdgeAlignedLeft ;
var lfs = new Commands . LFS ( _fullpath ) ;
if ( lfs . IsEnabled ( ) )
{
2024-06-17 23:14:13 -07:00
var addPattern = new MenuItem ( ) ;
addPattern . Header = App . Text ( "GitLFS.AddTrackPattern" ) ;
addPattern . Icon = App . CreateMenuIcon ( "Icons.File.Add" ) ;
2024-07-14 09:30:31 -07:00
addPattern . Click + = ( _ , e ) = >
2024-06-17 23:14:13 -07:00
{
if ( PopupHost . CanCreatePopup ( ) )
PopupHost . ShowPopup ( new LFSTrackCustomPattern ( this ) ) ;
e . Handled = true ;
} ;
menu . Items . Add ( addPattern ) ;
menu . Items . Add ( new MenuItem ( ) { Header = "-" } ) ;
2024-06-17 03:25:57 -07:00
var fetch = new MenuItem ( ) ;
fetch . Header = App . Text ( "GitLFS.Fetch" ) ;
fetch . Icon = App . CreateMenuIcon ( "Icons.Fetch" ) ;
2024-07-24 00:36:26 -07:00
fetch . IsEnabled = _remotes . Count > 0 ;
2024-07-14 09:30:31 -07:00
fetch . Click + = ( _ , e ) = >
2024-06-17 03:25:57 -07:00
{
if ( PopupHost . CanCreatePopup ( ) )
{
2024-07-24 00:36:26 -07:00
if ( _remotes . Count = = 1 )
2024-06-17 03:25:57 -07:00
PopupHost . ShowAndStartPopup ( new LFSFetch ( this ) ) ;
else
PopupHost . ShowPopup ( new LFSFetch ( this ) ) ;
}
e . Handled = true ;
} ;
menu . Items . Add ( fetch ) ;
var pull = new MenuItem ( ) ;
pull . Header = App . Text ( "GitLFS.Pull" ) ;
pull . Icon = App . CreateMenuIcon ( "Icons.Pull" ) ;
2024-07-24 00:36:26 -07:00
pull . IsEnabled = _remotes . Count > 0 ;
2024-07-14 09:30:31 -07:00
pull . Click + = ( _ , e ) = >
2024-06-17 03:25:57 -07:00
{
if ( PopupHost . CanCreatePopup ( ) )
{
2024-07-24 00:36:26 -07:00
if ( _remotes . Count = = 1 )
2024-06-17 03:25:57 -07:00
PopupHost . ShowAndStartPopup ( new LFSPull ( this ) ) ;
else
PopupHost . ShowPopup ( new LFSPull ( this ) ) ;
}
e . Handled = true ;
} ;
menu . Items . Add ( pull ) ;
2024-06-25 20:49:56 -07:00
var push = new MenuItem ( ) ;
push . Header = App . Text ( "GitLFS.Push" ) ;
push . Icon = App . CreateMenuIcon ( "Icons.Push" ) ;
2024-07-24 00:36:26 -07:00
push . IsEnabled = _remotes . Count > 0 ;
2024-07-14 09:30:31 -07:00
push . Click + = ( _ , e ) = >
2024-06-25 20:49:56 -07:00
{
if ( PopupHost . CanCreatePopup ( ) )
{
2024-07-24 00:36:26 -07:00
if ( _remotes . Count = = 1 )
2024-06-25 20:49:56 -07:00
PopupHost . ShowAndStartPopup ( new LFSPush ( this ) ) ;
else
PopupHost . ShowPopup ( new LFSPush ( this ) ) ;
}
e . Handled = true ;
} ;
menu . Items . Add ( push ) ;
2024-06-17 03:25:57 -07:00
var prune = new MenuItem ( ) ;
prune . Header = App . Text ( "GitLFS.Prune" ) ;
prune . Icon = App . CreateMenuIcon ( "Icons.Clean" ) ;
2024-07-14 09:30:31 -07:00
prune . Click + = ( _ , e ) = >
2024-06-17 03:25:57 -07:00
{
if ( PopupHost . CanCreatePopup ( ) )
PopupHost . ShowAndStartPopup ( new LFSPrune ( this ) ) ;
e . Handled = true ;
} ;
menu . Items . Add ( new MenuItem ( ) { Header = "-" } ) ;
menu . Items . Add ( prune ) ;
var locks = new MenuItem ( ) ;
locks . Header = App . Text ( "GitLFS.Locks" ) ;
locks . Icon = App . CreateMenuIcon ( "Icons.Lock" ) ;
2024-07-24 00:36:26 -07:00
locks . IsEnabled = _remotes . Count > 0 ;
if ( _remotes . Count = = 1 )
2024-06-17 03:25:57 -07:00
{
2024-07-14 09:30:31 -07:00
locks . Click + = ( _ , e ) = >
2024-06-25 20:49:56 -07:00
{
2024-07-24 00:36:26 -07:00
var dialog = new Views . LFSLocks ( ) { DataContext = new LFSLocks ( _fullpath , _remotes [ 0 ] . Name ) } ;
2024-08-18 21:49:04 -07:00
App . OpenDialog ( dialog ) ;
2024-06-25 20:49:56 -07:00
e . Handled = true ;
} ;
}
else
{
2024-07-24 00:36:26 -07:00
foreach ( var remote in _remotes )
2024-06-25 20:49:56 -07:00
{
var remoteName = remote . Name ;
var lockRemote = new MenuItem ( ) ;
lockRemote . Header = remoteName ;
2024-07-14 09:30:31 -07:00
lockRemote . Click + = ( _ , e ) = >
2024-06-25 20:49:56 -07:00
{
var dialog = new Views . LFSLocks ( ) { DataContext = new LFSLocks ( _fullpath , remoteName ) } ;
2024-08-18 21:49:04 -07:00
App . OpenDialog ( dialog ) ;
2024-06-25 20:49:56 -07:00
e . Handled = true ;
} ;
locks . Items . Add ( lockRemote ) ;
}
}
2024-06-17 03:25:57 -07:00
menu . Items . Add ( new MenuItem ( ) { Header = "-" } ) ;
menu . Items . Add ( locks ) ;
}
else
{
var install = new MenuItem ( ) ;
install . Header = App . Text ( "GitLFS.Install" ) ;
install . Icon = App . CreateMenuIcon ( "Icons.Init" ) ;
2024-07-14 09:30:31 -07:00
install . Click + = ( _ , e ) = >
2024-06-17 03:25:57 -07:00
{
var succ = new Commands . LFS ( _fullpath ) . Install ( ) ;
if ( succ )
App . SendNotification ( _fullpath , $"LFS enabled successfully!" ) ;
e . Handled = true ;
} ;
menu . Items . Add ( install ) ;
}
return menu ;
2024-02-05 23:08:37 -08:00
}
2024-03-17 18:37:06 -07:00
public ContextMenu CreateContextMenuForLocalBranch ( Models . Branch branch )
{
2024-02-05 23:08:37 -08:00
var menu = new ContextMenu ( ) ;
var push = new MenuItem ( ) ;
2024-02-28 02:55:23 -08:00
push . Header = new Views . NameHighlightedTextBlock ( "BranchCM.Push" , branch . Name ) ;
2024-02-27 02:26:05 -08:00
push . Icon = App . CreateMenuIcon ( "Icons.Push" ) ;
2024-07-24 00:36:26 -07:00
push . IsEnabled = _remotes . Count > 0 ;
2024-03-17 18:37:06 -07:00
push . Click + = ( _ , e ) = >
{
2024-03-31 01:54:29 -07:00
if ( PopupHost . CanCreatePopup ( ) )
PopupHost . ShowPopup ( new Push ( this , branch ) ) ;
2024-02-05 23:08:37 -08:00
e . Handled = true ;
} ;
2024-03-17 18:37:06 -07:00
if ( branch . IsCurrent )
{
2024-02-05 23:08:37 -08:00
var discard = new MenuItem ( ) ;
discard . Header = App . Text ( "BranchCM.DiscardAll" ) ;
2024-02-27 02:26:05 -08:00
discard . Icon = App . CreateMenuIcon ( "Icons.Undo" ) ;
2024-08-13 02:38:58 -07:00
discard . IsEnabled = _localChangesCount > 0 ;
2024-07-14 09:30:31 -07:00
discard . Click + = ( _ , e ) = >
2024-03-17 18:37:06 -07:00
{
2024-03-31 01:54:29 -07:00
if ( PopupHost . CanCreatePopup ( ) )
PopupHost . ShowPopup ( new Discard ( this ) ) ;
2024-02-05 23:08:37 -08:00
e . Handled = true ;
} ;
menu . Items . Add ( discard ) ;
menu . Items . Add ( new MenuItem ( ) { Header = "-" } ) ;
2024-03-17 18:37:06 -07:00
if ( ! string . IsNullOrEmpty ( branch . Upstream ) )
{
2024-02-05 23:08:37 -08:00
var upstream = branch . Upstream . Substring ( 13 ) ;
var fastForward = new MenuItem ( ) ;
2024-02-28 02:55:23 -08:00
fastForward . Header = new Views . NameHighlightedTextBlock ( "BranchCM.FastForward" , upstream ) ;
2024-02-27 02:26:05 -08:00
fastForward . Icon = App . CreateMenuIcon ( "Icons.FastForward" ) ;
2024-07-18 18:29:16 -07:00
fastForward . IsEnabled = branch . TrackStatus . Ahead . Count = = 0 ;
2024-07-14 09:30:31 -07:00
fastForward . Click + = ( _ , e ) = >
2024-03-17 18:37:06 -07:00
{
2024-03-31 01:54:29 -07:00
if ( PopupHost . CanCreatePopup ( ) )
PopupHost . ShowAndStartPopup ( new Merge ( this , upstream , branch . Name ) ) ;
2024-02-05 23:08:37 -08:00
e . Handled = true ;
} ;
var pull = new MenuItem ( ) ;
2024-02-28 02:55:23 -08:00
pull . Header = new Views . NameHighlightedTextBlock ( "BranchCM.Pull" , upstream ) ;
2024-02-27 02:26:05 -08:00
pull . Icon = App . CreateMenuIcon ( "Icons.Pull" ) ;
2024-07-14 09:30:31 -07:00
pull . Click + = ( _ , e ) = >
2024-03-17 18:37:06 -07:00
{
2024-03-31 01:54:29 -07:00
if ( PopupHost . CanCreatePopup ( ) )
PopupHost . ShowPopup ( new Pull ( this , null ) ) ;
2024-02-05 23:08:37 -08:00
e . Handled = true ;
} ;
menu . Items . Add ( fastForward ) ;
menu . Items . Add ( pull ) ;
}
menu . Items . Add ( push ) ;
2024-06-11 00:30:06 -07:00
var compareWithBranch = CreateMenuItemToCompareBranches ( branch ) ;
if ( compareWithBranch ! = null )
{
menu . Items . Add ( new MenuItem ( ) { Header = "-" } ) ;
menu . Items . Add ( compareWithBranch ) ;
}
2024-03-17 18:37:06 -07:00
}
else
{
2024-02-05 23:08:37 -08:00
var checkout = new MenuItem ( ) ;
2024-02-28 02:55:23 -08:00
checkout . Header = new Views . NameHighlightedTextBlock ( "BranchCM.Checkout" , branch . Name ) ;
2024-02-27 02:26:05 -08:00
checkout . Icon = App . CreateMenuIcon ( "Icons.Check" ) ;
2024-07-14 09:30:31 -07:00
checkout . Click + = ( _ , e ) = >
2024-03-17 18:37:06 -07:00
{
2024-05-29 01:42:47 -07:00
CheckoutBranch ( branch ) ;
2024-02-05 23:08:37 -08:00
e . Handled = true ;
} ;
menu . Items . Add ( checkout ) ;
2024-07-24 00:36:26 -07:00
var upstream = _branches . Find ( x = > x . FullName = = branch . Upstream ) ;
2024-03-17 18:37:06 -07:00
if ( upstream ! = null )
{
2024-02-05 23:08:37 -08:00
var fastForward = new MenuItem ( ) ;
2024-07-01 19:23:21 -07:00
fastForward . Header = new Views . NameHighlightedTextBlock ( "BranchCM.FastForward" , upstream . FriendlyName ) ;
2024-02-27 02:26:05 -08:00
fastForward . Icon = App . CreateMenuIcon ( "Icons.FastForward" ) ;
2024-07-18 18:29:16 -07:00
fastForward . IsEnabled = branch . TrackStatus . Ahead . Count = = 0 ;
2024-07-14 09:30:31 -07:00
fastForward . Click + = ( _ , e ) = >
2024-03-17 18:37:06 -07:00
{
2024-03-31 01:54:29 -07:00
if ( PopupHost . CanCreatePopup ( ) )
PopupHost . ShowAndStartPopup ( new FastForwardWithoutCheckout ( this , branch , upstream ) ) ;
2024-02-05 23:08:37 -08:00
e . Handled = true ;
} ;
menu . Items . Add ( new MenuItem ( ) { Header = "-" } ) ;
menu . Items . Add ( fastForward ) ;
}
menu . Items . Add ( new MenuItem ( ) { Header = "-" } ) ;
menu . Items . Add ( push ) ;
var merge = new MenuItem ( ) ;
2024-07-24 00:36:26 -07:00
merge . Header = new Views . NameHighlightedTextBlock ( "BranchCM.Merge" , branch . Name , _currentBranch . Name ) ;
2024-02-27 02:26:05 -08:00
merge . Icon = App . CreateMenuIcon ( "Icons.Merge" ) ;
2024-07-14 09:30:31 -07:00
merge . Click + = ( _ , e ) = >
2024-03-17 18:37:06 -07:00
{
2024-03-31 01:54:29 -07:00
if ( PopupHost . CanCreatePopup ( ) )
2024-07-24 00:36:26 -07:00
PopupHost . ShowPopup ( new Merge ( this , branch . Name , _currentBranch . Name ) ) ;
2024-02-05 23:08:37 -08:00
e . Handled = true ;
} ;
var rebase = new MenuItem ( ) ;
2024-07-24 00:36:26 -07:00
rebase . Header = new Views . NameHighlightedTextBlock ( "BranchCM.Rebase" , _currentBranch . Name , branch . Name ) ;
2024-02-27 02:26:05 -08:00
rebase . Icon = App . CreateMenuIcon ( "Icons.Rebase" ) ;
2024-07-14 09:30:31 -07:00
rebase . Click + = ( _ , e ) = >
2024-03-17 18:37:06 -07:00
{
2024-03-31 01:54:29 -07:00
if ( PopupHost . CanCreatePopup ( ) )
2024-07-24 00:36:26 -07:00
PopupHost . ShowPopup ( new Rebase ( this , _currentBranch , branch ) ) ;
2024-02-05 23:08:37 -08:00
e . Handled = true ;
} ;
menu . Items . Add ( merge ) ;
menu . Items . Add ( rebase ) ;
2024-05-27 02:21:28 -07:00
2024-08-13 02:38:58 -07:00
if ( _localChangesCount > 0 )
2024-05-27 06:05:15 -07:00
{
var compareWithWorktree = new MenuItem ( ) ;
compareWithWorktree . Header = App . Text ( "BranchCM.CompareWithWorktree" ) ;
compareWithWorktree . Icon = App . CreateMenuIcon ( "Icons.Compare" ) ;
2024-07-14 09:30:31 -07:00
compareWithWorktree . Click + = ( _ , _ ) = >
2024-05-27 06:05:15 -07:00
{
SearchResultSelectedCommit = null ;
if ( _histories ! = null )
{
2024-07-24 00:36:26 -07:00
var target = new Commands . QuerySingleCommit ( _fullpath , branch . Head ) . Result ( ) ;
2024-05-27 06:05:15 -07:00
_histories . AutoSelectedCommit = null ;
2024-07-24 00:36:26 -07:00
_histories . DetailContext = new RevisionCompare ( _fullpath , target , null ) ;
2024-05-27 06:05:15 -07:00
}
} ;
2024-06-11 00:30:06 -07:00
menu . Items . Add ( new MenuItem ( ) { Header = "-" } ) ;
2024-05-27 06:05:15 -07:00
menu . Items . Add ( compareWithWorktree ) ;
}
2024-06-11 00:30:06 -07:00
var compareWithBranch = CreateMenuItemToCompareBranches ( branch ) ;
if ( compareWithBranch ! = null )
{
2024-08-13 02:38:58 -07:00
if ( _localChangesCount = = 0 )
2024-06-11 00:30:06 -07:00
menu . Items . Add ( new MenuItem ( ) { Header = "-" } ) ;
menu . Items . Add ( compareWithBranch ) ;
2024-06-13 18:46:30 -07:00
}
2024-02-05 23:08:37 -08:00
}
2024-06-14 21:44:35 -07:00
var detect = Commands . GitFlow . DetectType ( _fullpath , _branches , branch . Name ) ;
if ( detect . IsGitFlowBranch )
2024-03-17 18:37:06 -07:00
{
2024-02-05 23:08:37 -08:00
var finish = new MenuItem ( ) ;
2024-02-28 02:55:23 -08:00
finish . Header = new Views . NameHighlightedTextBlock ( "BranchCM.Finish" , branch . Name ) ;
2024-06-26 00:51:49 -07:00
finish . Icon = App . CreateMenuIcon ( "Icons.GitFlow" ) ;
2024-07-14 09:30:31 -07:00
finish . Click + = ( _ , e ) = >
2024-03-17 18:37:06 -07:00
{
2024-03-31 01:54:29 -07:00
if ( PopupHost . CanCreatePopup ( ) )
2024-06-14 21:44:35 -07:00
PopupHost . ShowPopup ( new GitFlowFinish ( this , branch , detect . Type , detect . Prefix ) ) ;
2024-02-05 23:08:37 -08:00
e . Handled = true ;
} ;
menu . Items . Add ( new MenuItem ( ) { Header = "-" } ) ;
menu . Items . Add ( finish ) ;
}
var rename = new MenuItem ( ) ;
2024-02-28 02:55:23 -08:00
rename . Header = new Views . NameHighlightedTextBlock ( "BranchCM.Rename" , branch . Name ) ;
2024-02-27 02:26:05 -08:00
rename . Icon = App . CreateMenuIcon ( "Icons.Rename" ) ;
2024-07-14 09:30:31 -07:00
rename . Click + = ( _ , e ) = >
2024-03-17 18:37:06 -07:00
{
2024-03-31 01:54:29 -07:00
if ( PopupHost . CanCreatePopup ( ) )
PopupHost . ShowPopup ( new RenameBranch ( this , branch ) ) ;
2024-02-05 23:08:37 -08:00
e . Handled = true ;
} ;
var delete = new MenuItem ( ) ;
2024-02-28 02:55:23 -08:00
delete . Header = new Views . NameHighlightedTextBlock ( "BranchCM.Delete" , branch . Name ) ;
2024-02-27 02:26:05 -08:00
delete . Icon = App . CreateMenuIcon ( "Icons.Clear" ) ;
2024-02-05 23:08:37 -08:00
delete . IsEnabled = ! branch . IsCurrent ;
2024-07-14 09:30:31 -07:00
delete . Click + = ( _ , e ) = >
2024-03-17 18:37:06 -07:00
{
2024-03-31 01:54:29 -07:00
if ( PopupHost . CanCreatePopup ( ) )
PopupHost . ShowPopup ( new DeleteBranch ( this , branch ) ) ;
2024-02-05 23:08:37 -08:00
e . Handled = true ;
} ;
var createBranch = new MenuItem ( ) ;
2024-02-27 02:26:05 -08:00
createBranch . Icon = App . CreateMenuIcon ( "Icons.Branch.Add" ) ;
2024-02-05 23:08:37 -08:00
createBranch . Header = App . Text ( "CreateBranch" ) ;
2024-07-14 09:30:31 -07:00
createBranch . Click + = ( _ , e ) = >
2024-03-17 18:37:06 -07:00
{
2024-03-31 01:54:29 -07:00
if ( PopupHost . CanCreatePopup ( ) )
PopupHost . ShowPopup ( new CreateBranch ( this , branch ) ) ;
2024-02-05 23:08:37 -08:00
e . Handled = true ;
} ;
var createTag = new MenuItem ( ) ;
2024-02-27 02:26:05 -08:00
createTag . Icon = App . CreateMenuIcon ( "Icons.Tag.Add" ) ;
2024-02-05 23:08:37 -08:00
createTag . Header = App . Text ( "CreateTag" ) ;
2024-07-14 09:30:31 -07:00
createTag . Click + = ( _ , e ) = >
2024-03-17 18:37:06 -07:00
{
2024-03-31 01:54:29 -07:00
if ( PopupHost . CanCreatePopup ( ) )
PopupHost . ShowPopup ( new CreateTag ( this , branch ) ) ;
2024-02-05 23:08:37 -08:00
e . Handled = true ;
} ;
menu . Items . Add ( new MenuItem ( ) { Header = "-" } ) ;
menu . Items . Add ( rename ) ;
menu . Items . Add ( delete ) ;
menu . Items . Add ( new MenuItem ( ) { Header = "-" } ) ;
menu . Items . Add ( createBranch ) ;
menu . Items . Add ( createTag ) ;
menu . Items . Add ( new MenuItem ( ) { Header = "-" } ) ;
var remoteBranches = new List < Models . Branch > ( ) ;
2024-07-24 00:36:26 -07:00
foreach ( var b in _branches )
2024-03-17 18:37:06 -07:00
{
2024-03-31 01:54:29 -07:00
if ( ! b . IsLocal )
remoteBranches . Add ( b ) ;
2024-02-05 23:08:37 -08:00
}
2024-03-17 18:37:06 -07:00
if ( remoteBranches . Count > 0 )
{
2024-02-05 23:08:37 -08:00
var tracking = new MenuItem ( ) ;
tracking . Header = App . Text ( "BranchCM.Tracking" ) ;
2024-06-17 23:55:22 -07:00
tracking . Icon = App . CreateMenuIcon ( "Icons.Track" ) ;
2024-02-05 23:08:37 -08:00
2024-03-17 18:37:06 -07:00
foreach ( var b in remoteBranches )
{
2024-02-05 23:08:37 -08:00
var upstream = b . FullName . Replace ( "refs/remotes/" , "" ) ;
var target = new MenuItem ( ) ;
target . Header = upstream ;
2024-03-31 01:54:29 -07:00
if ( branch . Upstream = = b . FullName )
target . Icon = App . CreateMenuIcon ( "Icons.Check" ) ;
2024-02-05 23:08:37 -08:00
2024-07-14 09:30:31 -07:00
target . Click + = ( _ , e ) = >
2024-03-17 18:37:06 -07:00
{
if ( Commands . Branch . SetUpstream ( _fullpath , branch . Name , upstream ) )
2024-02-05 23:08:37 -08:00
Task . Run ( RefreshBranches ) ;
2024-06-27 03:25:16 -07:00
2024-02-05 23:08:37 -08:00
e . Handled = true ;
} ;
tracking . Items . Add ( target ) ;
}
var unsetUpstream = new MenuItem ( ) ;
unsetUpstream . Header = App . Text ( "BranchCM.UnsetUpstream" ) ;
2024-03-17 18:37:06 -07:00
unsetUpstream . Click + = ( _ , e ) = >
{
if ( Commands . Branch . SetUpstream ( _fullpath , branch . Name , string . Empty ) )
2024-02-05 23:08:37 -08:00
Task . Run ( RefreshBranches ) ;
2024-06-27 03:25:16 -07:00
2024-02-05 23:08:37 -08:00
e . Handled = true ;
} ;
tracking . Items . Add ( new MenuItem ( ) { Header = "-" } ) ;
tracking . Items . Add ( unsetUpstream ) ;
menu . Items . Add ( tracking ) ;
}
var archive = new MenuItem ( ) ;
2024-02-27 02:26:05 -08:00
archive . Icon = App . CreateMenuIcon ( "Icons.Archive" ) ;
2024-02-05 23:08:37 -08:00
archive . Header = App . Text ( "Archive" ) ;
2024-07-14 09:30:31 -07:00
archive . Click + = ( _ , e ) = >
2024-03-17 18:37:06 -07:00
{
2024-03-31 01:54:29 -07:00
if ( PopupHost . CanCreatePopup ( ) )
PopupHost . ShowPopup ( new Archive ( this , branch ) ) ;
2024-02-05 23:08:37 -08:00
e . Handled = true ;
} ;
menu . Items . Add ( archive ) ;
menu . Items . Add ( new MenuItem ( ) { Header = "-" } ) ;
var copy = new MenuItem ( ) ;
copy . Header = App . Text ( "BranchCM.CopyName" ) ;
2024-02-27 02:26:05 -08:00
copy . Icon = App . CreateMenuIcon ( "Icons.Copy" ) ;
2024-07-14 09:30:31 -07:00
copy . Click + = ( _ , e ) = >
2024-03-17 18:37:06 -07:00
{
2024-02-05 23:08:37 -08:00
App . CopyText ( branch . Name ) ;
e . Handled = true ;
} ;
menu . Items . Add ( copy ) ;
return menu ;
}
2024-03-17 18:37:06 -07:00
public ContextMenu CreateContextMenuForRemote ( Models . Remote remote )
{
2024-02-05 23:08:37 -08:00
var menu = new ContextMenu ( ) ;
2024-06-17 05:31:54 -07:00
if ( remote . TryGetVisitURL ( out string visitURL ) )
{
var visit = new MenuItem ( ) ;
visit . Header = App . Text ( "RemoteCM.OpenInBrowser" ) ;
visit . Icon = App . CreateMenuIcon ( "Icons.OpenWith" ) ;
2024-07-14 09:30:31 -07:00
visit . Click + = ( _ , e ) = >
2024-06-17 05:31:54 -07:00
{
Native . OS . OpenBrowser ( visitURL ) ;
e . Handled = true ;
} ;
menu . Items . Add ( visit ) ;
menu . Items . Add ( new MenuItem ( ) { Header = "-" } ) ;
}
2024-02-05 23:08:37 -08:00
var fetch = new MenuItem ( ) ;
fetch . Header = App . Text ( "RemoteCM.Fetch" ) ;
2024-02-27 02:26:05 -08:00
fetch . Icon = App . CreateMenuIcon ( "Icons.Fetch" ) ;
2024-07-14 09:30:31 -07:00
fetch . Click + = ( _ , e ) = >
2024-03-17 18:37:06 -07:00
{
2024-03-31 01:54:29 -07:00
if ( PopupHost . CanCreatePopup ( ) )
PopupHost . ShowAndStartPopup ( new Fetch ( this , remote ) ) ;
2024-02-05 23:08:37 -08:00
e . Handled = true ;
} ;
var prune = new MenuItem ( ) ;
prune . Header = App . Text ( "RemoteCM.Prune" ) ;
2024-06-17 04:44:54 -07:00
prune . Icon = App . CreateMenuIcon ( "Icons.Clean" ) ;
2024-07-14 09:30:31 -07:00
prune . Click + = ( _ , e ) = >
2024-03-17 18:37:06 -07:00
{
2024-03-31 01:54:29 -07:00
if ( PopupHost . CanCreatePopup ( ) )
PopupHost . ShowAndStartPopup ( new PruneRemote ( this , remote ) ) ;
2024-02-05 23:08:37 -08:00
e . Handled = true ;
} ;
var edit = new MenuItem ( ) ;
edit . Header = App . Text ( "RemoteCM.Edit" ) ;
2024-02-27 02:26:05 -08:00
edit . Icon = App . CreateMenuIcon ( "Icons.Edit" ) ;
2024-07-14 09:30:31 -07:00
edit . Click + = ( _ , e ) = >
2024-03-17 18:37:06 -07:00
{
2024-03-31 01:54:29 -07:00
if ( PopupHost . CanCreatePopup ( ) )
PopupHost . ShowPopup ( new EditRemote ( this , remote ) ) ;
2024-02-05 23:08:37 -08:00
e . Handled = true ;
} ;
var delete = new MenuItem ( ) ;
delete . Header = App . Text ( "RemoteCM.Delete" ) ;
2024-02-27 02:26:05 -08:00
delete . Icon = App . CreateMenuIcon ( "Icons.Clear" ) ;
2024-07-14 09:30:31 -07:00
delete . Click + = ( _ , e ) = >
2024-03-17 18:37:06 -07:00
{
2024-03-31 01:54:29 -07:00
if ( PopupHost . CanCreatePopup ( ) )
PopupHost . ShowPopup ( new DeleteRemote ( this , remote ) ) ;
2024-02-05 23:08:37 -08:00
e . Handled = true ;
} ;
var copy = new MenuItem ( ) ;
copy . Header = App . Text ( "RemoteCM.CopyURL" ) ;
2024-02-27 02:26:05 -08:00
copy . Icon = App . CreateMenuIcon ( "Icons.Copy" ) ;
2024-07-14 09:30:31 -07:00
copy . Click + = ( _ , e ) = >
2024-03-17 18:37:06 -07:00
{
2024-02-05 23:08:37 -08:00
App . CopyText ( remote . URL ) ;
e . Handled = true ;
} ;
menu . Items . Add ( fetch ) ;
menu . Items . Add ( prune ) ;
menu . Items . Add ( new MenuItem ( ) { Header = "-" } ) ;
menu . Items . Add ( edit ) ;
menu . Items . Add ( delete ) ;
menu . Items . Add ( new MenuItem ( ) { Header = "-" } ) ;
menu . Items . Add ( copy ) ;
return menu ;
}
2024-03-17 18:37:06 -07:00
public ContextMenu CreateContextMenuForRemoteBranch ( Models . Branch branch )
{
2024-02-05 23:08:37 -08:00
var menu = new ContextMenu ( ) ;
2024-07-01 19:23:21 -07:00
var name = branch . FriendlyName ;
2024-02-05 23:08:37 -08:00
var checkout = new MenuItem ( ) ;
2024-07-01 19:23:21 -07:00
checkout . Header = new Views . NameHighlightedTextBlock ( "BranchCM.Checkout" , name ) ;
2024-02-27 02:26:05 -08:00
checkout . Icon = App . CreateMenuIcon ( "Icons.Check" ) ;
2024-07-14 09:30:31 -07:00
checkout . Click + = ( _ , e ) = >
2024-03-17 18:37:06 -07:00
{
2024-05-29 01:42:47 -07:00
CheckoutBranch ( branch ) ;
2024-02-05 23:08:37 -08:00
e . Handled = true ;
} ;
menu . Items . Add ( checkout ) ;
menu . Items . Add ( new MenuItem ( ) { Header = "-" } ) ;
2024-07-24 00:36:26 -07:00
if ( _currentBranch ! = null )
2024-03-17 18:37:06 -07:00
{
2024-02-05 23:08:37 -08:00
var pull = new MenuItem ( ) ;
2024-07-24 00:36:26 -07:00
pull . Header = new Views . NameHighlightedTextBlock ( "BranchCM.PullInto" , name , _currentBranch . Name ) ;
2024-02-27 02:26:05 -08:00
pull . Icon = App . CreateMenuIcon ( "Icons.Pull" ) ;
2024-07-14 09:30:31 -07:00
pull . Click + = ( _ , e ) = >
2024-03-17 18:37:06 -07:00
{
2024-03-31 01:54:29 -07:00
if ( PopupHost . CanCreatePopup ( ) )
PopupHost . ShowPopup ( new Pull ( this , branch ) ) ;
2024-02-05 23:08:37 -08:00
e . Handled = true ;
} ;
var merge = new MenuItem ( ) ;
2024-07-24 00:36:26 -07:00
merge . Header = new Views . NameHighlightedTextBlock ( "BranchCM.Merge" , name , _currentBranch . Name ) ;
2024-02-27 02:26:05 -08:00
merge . Icon = App . CreateMenuIcon ( "Icons.Merge" ) ;
2024-07-14 09:30:31 -07:00
merge . Click + = ( _ , e ) = >
2024-03-17 18:37:06 -07:00
{
2024-03-31 01:54:29 -07:00
if ( PopupHost . CanCreatePopup ( ) )
2024-07-24 00:36:26 -07:00
PopupHost . ShowPopup ( new Merge ( this , name , _currentBranch . Name ) ) ;
2024-02-05 23:08:37 -08:00
e . Handled = true ;
} ;
var rebase = new MenuItem ( ) ;
2024-07-24 00:36:26 -07:00
rebase . Header = new Views . NameHighlightedTextBlock ( "BranchCM.Rebase" , _currentBranch . Name , name ) ;
2024-02-27 02:26:05 -08:00
rebase . Icon = App . CreateMenuIcon ( "Icons.Rebase" ) ;
2024-07-14 09:30:31 -07:00
rebase . Click + = ( _ , e ) = >
2024-03-17 18:37:06 -07:00
{
2024-03-31 01:54:29 -07:00
if ( PopupHost . CanCreatePopup ( ) )
2024-07-24 00:36:26 -07:00
PopupHost . ShowPopup ( new Rebase ( this , _currentBranch , branch ) ) ;
2024-02-05 23:08:37 -08:00
e . Handled = true ;
} ;
menu . Items . Add ( pull ) ;
menu . Items . Add ( merge ) ;
menu . Items . Add ( rebase ) ;
menu . Items . Add ( new MenuItem ( ) { Header = "-" } ) ;
2024-06-11 00:30:06 -07:00
}
2024-05-27 02:21:28 -07:00
2024-06-11 00:30:06 -07:00
var hasCompare = false ;
2024-08-13 02:38:58 -07:00
if ( _localChangesCount > 0 )
2024-06-11 00:30:06 -07:00
{
var compareWithWorktree = new MenuItem ( ) ;
compareWithWorktree . Header = App . Text ( "BranchCM.CompareWithWorktree" ) ;
compareWithWorktree . Icon = App . CreateMenuIcon ( "Icons.Compare" ) ;
2024-07-14 09:30:31 -07:00
compareWithWorktree . Click + = ( _ , _ ) = >
2024-05-27 02:21:28 -07:00
{
2024-06-11 00:30:06 -07:00
SearchResultSelectedCommit = null ;
2024-05-27 06:05:15 -07:00
2024-06-11 00:30:06 -07:00
if ( _histories ! = null )
2024-05-27 06:05:15 -07:00
{
2024-07-24 00:36:26 -07:00
var target = new Commands . QuerySingleCommit ( _fullpath , branch . Head ) . Result ( ) ;
2024-06-11 00:30:06 -07:00
_histories . AutoSelectedCommit = null ;
2024-07-24 00:36:26 -07:00
_histories . DetailContext = new RevisionCompare ( _fullpath , target , null ) ;
2024-05-27 06:05:15 -07:00
}
2024-06-11 00:30:06 -07:00
} ;
menu . Items . Add ( compareWithWorktree ) ;
hasCompare = true ;
}
2024-05-27 06:05:15 -07:00
2024-06-11 00:30:06 -07:00
var compareWithBranch = CreateMenuItemToCompareBranches ( branch ) ;
if ( compareWithBranch ! = null )
{
menu . Items . Add ( compareWithBranch ) ;
hasCompare = true ;
2024-02-05 23:08:37 -08:00
}
2024-06-11 00:30:06 -07:00
if ( hasCompare )
menu . Items . Add ( new MenuItem ( ) { Header = "-" } ) ;
2024-02-05 23:08:37 -08:00
var delete = new MenuItem ( ) ;
2024-07-01 19:23:21 -07:00
delete . Header = new Views . NameHighlightedTextBlock ( "BranchCM.Delete" , name ) ;
2024-02-27 02:26:05 -08:00
delete . Icon = App . CreateMenuIcon ( "Icons.Clear" ) ;
2024-07-14 09:30:31 -07:00
delete . Click + = ( _ , e ) = >
2024-03-17 18:37:06 -07:00
{
2024-03-31 01:54:29 -07:00
if ( PopupHost . CanCreatePopup ( ) )
PopupHost . ShowPopup ( new DeleteBranch ( this , branch ) ) ;
2024-02-05 23:08:37 -08:00
e . Handled = true ;
} ;
var createBranch = new MenuItem ( ) ;
2024-02-27 02:26:05 -08:00
createBranch . Icon = App . CreateMenuIcon ( "Icons.Branch.Add" ) ;
2024-02-05 23:08:37 -08:00
createBranch . Header = App . Text ( "CreateBranch" ) ;
2024-07-14 09:30:31 -07:00
createBranch . Click + = ( _ , e ) = >
2024-03-17 18:37:06 -07:00
{
2024-03-31 01:54:29 -07:00
if ( PopupHost . CanCreatePopup ( ) )
PopupHost . ShowPopup ( new CreateBranch ( this , branch ) ) ;
2024-02-05 23:08:37 -08:00
e . Handled = true ;
} ;
var createTag = new MenuItem ( ) ;
2024-02-27 02:26:05 -08:00
createTag . Icon = App . CreateMenuIcon ( "Icons.Tag.Add" ) ;
2024-02-05 23:08:37 -08:00
createTag . Header = App . Text ( "CreateTag" ) ;
2024-07-14 09:30:31 -07:00
createTag . Click + = ( _ , e ) = >
2024-03-17 18:37:06 -07:00
{
2024-03-31 01:54:29 -07:00
if ( PopupHost . CanCreatePopup ( ) )
PopupHost . ShowPopup ( new CreateTag ( this , branch ) ) ;
2024-02-05 23:08:37 -08:00
e . Handled = true ;
} ;
var archive = new MenuItem ( ) ;
2024-02-27 02:26:05 -08:00
archive . Icon = App . CreateMenuIcon ( "Icons.Archive" ) ;
2024-02-05 23:08:37 -08:00
archive . Header = App . Text ( "Archive" ) ;
2024-07-14 09:30:31 -07:00
archive . Click + = ( _ , e ) = >
2024-03-17 18:37:06 -07:00
{
2024-03-31 01:54:29 -07:00
if ( PopupHost . CanCreatePopup ( ) )
PopupHost . ShowPopup ( new Archive ( this , branch ) ) ;
2024-02-05 23:08:37 -08:00
e . Handled = true ;
} ;
var copy = new MenuItem ( ) ;
copy . Header = App . Text ( "BranchCM.CopyName" ) ;
2024-02-27 02:26:05 -08:00
copy . Icon = App . CreateMenuIcon ( "Icons.Copy" ) ;
2024-07-14 09:30:31 -07:00
copy . Click + = ( _ , e ) = >
2024-03-17 18:37:06 -07:00
{
2024-07-01 19:23:21 -07:00
App . CopyText ( name ) ;
2024-02-05 23:08:37 -08:00
e . Handled = true ;
} ;
menu . Items . Add ( delete ) ;
menu . Items . Add ( new MenuItem ( ) { Header = "-" } ) ;
menu . Items . Add ( createBranch ) ;
menu . Items . Add ( createTag ) ;
menu . Items . Add ( new MenuItem ( ) { Header = "-" } ) ;
menu . Items . Add ( archive ) ;
menu . Items . Add ( new MenuItem ( ) { Header = "-" } ) ;
menu . Items . Add ( copy ) ;
return menu ;
}
2024-03-17 18:37:06 -07:00
public ContextMenu CreateContextMenuForTag ( Models . Tag tag )
{
2024-02-05 23:08:37 -08:00
var createBranch = new MenuItem ( ) ;
2024-02-27 02:26:05 -08:00
createBranch . Icon = App . CreateMenuIcon ( "Icons.Branch.Add" ) ;
2024-02-05 23:08:37 -08:00
createBranch . Header = App . Text ( "CreateBranch" ) ;
2024-07-14 09:30:31 -07:00
createBranch . Click + = ( _ , ev ) = >
2024-03-17 18:37:06 -07:00
{
2024-03-31 01:54:29 -07:00
if ( PopupHost . CanCreatePopup ( ) )
PopupHost . ShowPopup ( new CreateBranch ( this , tag ) ) ;
2024-02-05 23:08:37 -08:00
ev . Handled = true ;
} ;
var pushTag = new MenuItem ( ) ;
2024-02-28 02:55:23 -08:00
pushTag . Header = new Views . NameHighlightedTextBlock ( "TagCM.Push" , tag . Name ) ;
2024-02-27 02:26:05 -08:00
pushTag . Icon = App . CreateMenuIcon ( "Icons.Push" ) ;
2024-07-24 00:36:26 -07:00
pushTag . IsEnabled = _remotes . Count > 0 ;
2024-07-14 09:30:31 -07:00
pushTag . Click + = ( _ , ev ) = >
2024-03-17 18:37:06 -07:00
{
2024-03-31 01:54:29 -07:00
if ( PopupHost . CanCreatePopup ( ) )
PopupHost . ShowPopup ( new PushTag ( this , tag ) ) ;
2024-02-05 23:08:37 -08:00
ev . Handled = true ;
} ;
var deleteTag = new MenuItem ( ) ;
2024-02-28 02:55:23 -08:00
deleteTag . Header = new Views . NameHighlightedTextBlock ( "TagCM.Delete" , tag . Name ) ;
2024-02-27 02:26:05 -08:00
deleteTag . Icon = App . CreateMenuIcon ( "Icons.Clear" ) ;
2024-07-14 09:30:31 -07:00
deleteTag . Click + = ( _ , ev ) = >
2024-03-17 18:37:06 -07:00
{
2024-03-31 01:54:29 -07:00
if ( PopupHost . CanCreatePopup ( ) )
PopupHost . ShowPopup ( new DeleteTag ( this , tag ) ) ;
2024-02-05 23:08:37 -08:00
ev . Handled = true ;
} ;
var archive = new MenuItem ( ) ;
2024-02-27 02:26:05 -08:00
archive . Icon = App . CreateMenuIcon ( "Icons.Archive" ) ;
2024-02-05 23:08:37 -08:00
archive . Header = App . Text ( "Archive" ) ;
2024-07-14 09:30:31 -07:00
archive . Click + = ( _ , ev ) = >
2024-03-17 18:37:06 -07:00
{
2024-03-31 01:54:29 -07:00
if ( PopupHost . CanCreatePopup ( ) )
PopupHost . ShowPopup ( new Archive ( this , tag ) ) ;
2024-02-05 23:08:37 -08:00
ev . Handled = true ;
} ;
var copy = new MenuItem ( ) ;
copy . Header = App . Text ( "TagCM.Copy" ) ;
2024-02-27 02:26:05 -08:00
copy . Icon = App . CreateMenuIcon ( "Icons.Copy" ) ;
2024-07-14 09:30:31 -07:00
copy . Click + = ( _ , ev ) = >
2024-03-17 18:37:06 -07:00
{
2024-02-05 23:08:37 -08:00
App . CopyText ( tag . Name ) ;
ev . Handled = true ;
} ;
var menu = new ContextMenu ( ) ;
menu . Items . Add ( createBranch ) ;
menu . Items . Add ( new MenuItem ( ) { Header = "-" } ) ;
menu . Items . Add ( pushTag ) ;
menu . Items . Add ( deleteTag ) ;
menu . Items . Add ( new MenuItem ( ) { Header = "-" } ) ;
menu . Items . Add ( archive ) ;
menu . Items . Add ( new MenuItem ( ) { Header = "-" } ) ;
menu . Items . Add ( copy ) ;
return menu ;
}
2024-03-17 18:37:06 -07:00
public ContextMenu CreateContextMenuForSubmodule ( string submodule )
{
2024-02-05 23:08:37 -08:00
var open = new MenuItem ( ) ;
open . Header = App . Text ( "Submodule.Open" ) ;
2024-02-27 02:26:05 -08:00
open . Icon = App . CreateMenuIcon ( "Icons.Folder.Open" ) ;
2024-07-14 09:30:31 -07:00
open . Click + = ( _ , ev ) = >
2024-03-17 18:37:06 -07:00
{
2024-06-19 11:24:33 -07:00
OpenSubmodule ( submodule ) ;
2024-02-05 23:08:37 -08:00
ev . Handled = true ;
} ;
var copy = new MenuItem ( ) ;
copy . Header = App . Text ( "Submodule.CopyPath" ) ;
2024-02-27 02:26:05 -08:00
copy . Icon = App . CreateMenuIcon ( "Icons.Copy" ) ;
2024-07-14 09:30:31 -07:00
copy . Click + = ( _ , ev ) = >
2024-03-17 18:37:06 -07:00
{
2024-02-05 23:08:37 -08:00
App . CopyText ( submodule ) ;
ev . Handled = true ;
} ;
var rm = new MenuItem ( ) ;
rm . Header = App . Text ( "Submodule.Remove" ) ;
2024-02-27 02:26:05 -08:00
rm . Icon = App . CreateMenuIcon ( "Icons.Clear" ) ;
2024-07-14 09:30:31 -07:00
rm . Click + = ( _ , ev ) = >
2024-03-17 18:37:06 -07:00
{
2024-03-31 01:54:29 -07:00
if ( PopupHost . CanCreatePopup ( ) )
PopupHost . ShowPopup ( new DeleteSubmodule ( this , submodule ) ) ;
2024-02-05 23:08:37 -08:00
ev . Handled = true ;
} ;
var menu = new ContextMenu ( ) ;
menu . Items . Add ( open ) ;
menu . Items . Add ( copy ) ;
menu . Items . Add ( rm ) ;
return menu ;
}
2024-06-27 03:25:16 -07:00
public ContextMenu CreateContextMenuForWorktree ( Models . Worktree worktree )
{
var menu = new ContextMenu ( ) ;
if ( worktree . IsLocked )
{
var unlock = new MenuItem ( ) ;
unlock . Header = App . Text ( "Worktree.Unlock" ) ;
unlock . Icon = App . CreateMenuIcon ( "Icons.Unlock" ) ;
2024-07-14 09:30:31 -07:00
unlock . Click + = ( _ , ev ) = >
2024-06-27 03:25:16 -07:00
{
SetWatcherEnabled ( false ) ;
var succ = new Commands . Worktree ( _fullpath ) . Unlock ( worktree . FullPath ) ;
if ( succ )
worktree . IsLocked = false ;
SetWatcherEnabled ( true ) ;
ev . Handled = true ;
} ;
menu . Items . Add ( unlock ) ;
}
else
{
var loc = new MenuItem ( ) ;
loc . Header = App . Text ( "Worktree.Lock" ) ;
loc . Icon = App . CreateMenuIcon ( "Icons.Lock" ) ;
2024-07-14 09:30:31 -07:00
loc . Click + = ( _ , ev ) = >
2024-06-27 03:25:16 -07:00
{
2024-06-27 04:19:21 -07:00
SetWatcherEnabled ( false ) ;
var succ = new Commands . Worktree ( _fullpath ) . Lock ( worktree . FullPath ) ;
if ( succ )
worktree . IsLocked = true ;
SetWatcherEnabled ( true ) ;
2024-06-27 03:25:16 -07:00
ev . Handled = true ;
} ;
menu . Items . Add ( loc ) ;
}
var remove = new MenuItem ( ) ;
remove . Header = App . Text ( "Worktree.Remove" ) ;
remove . Icon = App . CreateMenuIcon ( "Icons.Clear" ) ;
2024-07-14 09:30:31 -07:00
remove . Click + = ( _ , ev ) = >
2024-06-27 03:25:16 -07:00
{
if ( PopupHost . CanCreatePopup ( ) )
PopupHost . ShowPopup ( new RemoveWorktree ( this , worktree ) ) ;
ev . Handled = true ;
} ;
menu . Items . Add ( remove ) ;
var copy = new MenuItem ( ) ;
copy . Header = App . Text ( "Worktree.CopyPath" ) ;
copy . Icon = App . CreateMenuIcon ( "Icons.Copy" ) ;
2024-07-14 09:30:31 -07:00
copy . Click + = ( _ , e ) = >
2024-06-27 03:25:16 -07:00
{
App . CopyText ( worktree . FullPath ) ;
e . Handled = true ;
} ;
menu . Items . Add ( new MenuItem ( ) { Header = "-" } ) ;
menu . Items . Add ( copy ) ;
return menu ;
}
2024-06-11 00:30:06 -07:00
private MenuItem CreateMenuItemToCompareBranches ( Models . Branch branch )
{
2024-07-24 00:36:26 -07:00
if ( _branches . Count = = 1 )
2024-06-11 00:30:06 -07:00
return null ;
var compare = new MenuItem ( ) ;
compare . Header = App . Text ( "BranchCM.CompareWithBranch" ) ;
compare . Icon = App . CreateMenuIcon ( "Icons.Compare" ) ;
2024-07-24 00:36:26 -07:00
foreach ( var b in _branches )
2024-06-11 00:30:06 -07:00
{
if ( b . FullName ! = branch . FullName )
{
var dup = b ;
var target = new MenuItem ( ) ;
2024-07-01 19:23:21 -07:00
target . Header = b . FriendlyName ;
2024-06-11 00:30:06 -07:00
target . Icon = App . CreateMenuIcon ( b . IsCurrent ? "Icons.Check" : "Icons.Branch" ) ;
target . Click + = ( _ , e ) = >
{
2024-08-19 20:53:37 -07:00
App . OpenDialog ( new Views . BranchCompare ( )
{
DataContext = new BranchCompare ( _fullpath , branch , dup )
2024-08-18 21:49:04 -07:00
} ) ;
2024-06-11 00:30:06 -07:00
e . Handled = true ;
} ;
compare . Items . Add ( target ) ;
}
}
return compare ;
}
2024-05-13 20:47:56 -07:00
private BranchTreeNode . Builder BuildBranchTree ( List < Models . Branch > branches , List < Models . Remote > remotes )
{
var builder = new BranchTreeNode . Builder ( ) ;
2024-06-30 20:57:13 -07:00
builder . SetFilters ( _settings . Filters ) ;
2024-05-13 20:47:56 -07:00
if ( string . IsNullOrEmpty ( _searchBranchFilter ) )
{
builder . CollectExpandedNodes ( _localBranchTrees , true ) ;
builder . CollectExpandedNodes ( _remoteBranchTrees , false ) ;
builder . Run ( branches , remotes , false ) ;
}
else
{
var visibles = new List < Models . Branch > ( ) ;
foreach ( var b in branches )
{
if ( b . FullName . Contains ( _searchBranchFilter , StringComparison . OrdinalIgnoreCase ) )
visibles . Add ( b ) ;
}
2024-07-06 02:17:41 -07:00
builder . Run ( visibles , remotes , true ) ;
2024-05-13 20:47:56 -07:00
}
return builder ;
}
2024-06-27 06:43:15 -07:00
private List < Models . Tag > BuildVisibleTags ( )
{
var visible = new List < Models . Tag > ( ) ;
if ( string . IsNullOrEmpty ( _searchBranchFilter ) )
{
visible . AddRange ( _tags ) ;
}
else
{
foreach ( var t in _tags )
{
if ( t . Name . Contains ( _searchBranchFilter , StringComparison . OrdinalIgnoreCase ) )
visible . Add ( t ) ;
}
}
return visible ;
}
2024-07-30 00:59:54 -07:00
private void UpdateCurrentRevisionFilesForSearchSuggestion ( )
{
_revisionFiles . Clear ( ) ;
if ( _searchCommitFilterType = = 3 )
{
Task . Run ( ( ) = >
{
var files = new Commands . QueryCurrentRevisionFiles ( _fullpath ) . Result ( ) ;
Dispatcher . UIThread . Invoke ( ( ) = > _revisionFiles . AddRange ( files ) ) ;
} ) ;
}
}
2024-02-05 23:08:37 -08:00
private string _fullpath = string . Empty ;
private string _gitDir = string . Empty ;
2024-07-22 23:52:25 -07:00
private Models . RepositorySettings _settings = null ;
2024-02-05 23:08:37 -08:00
private Models . Watcher _watcher = null ;
private Histories _histories = null ;
private WorkingCopy _workingCopy = null ;
private StashesPage _stashesPage = null ;
private int _selectedViewIndex = 0 ;
private object _selectedView = null ;
2024-08-13 02:38:58 -07:00
private int _localChangesCount = 0 ;
private int _stashesCount = 0 ;
2024-02-05 23:08:37 -08:00
private bool _isSearching = false ;
2024-07-09 00:15:31 -07:00
private bool _isSearchLoadingVisible = false ;
2024-07-30 00:59:54 -07:00
private bool _isSearchCommitSuggestionOpen = false ;
2024-06-07 03:43:37 -07:00
private int _searchCommitFilterType = 0 ;
2024-08-21 04:45:32 -07:00
private bool _enableFirstParentInHistories = false ;
2024-02-05 23:08:37 -08:00
private string _searchCommitFilter = string . Empty ;
private List < Models . Commit > _searchedCommits = new List < Models . Commit > ( ) ;
2024-07-30 00:59:54 -07:00
private List < string > _revisionFiles = new List < string > ( ) ;
2024-02-05 23:08:37 -08:00
2024-07-04 02:59:32 -07:00
private bool _isLocalBranchGroupExpanded = true ;
private bool _isRemoteGroupExpanded = false ;
2024-03-20 20:40:17 -07:00
private bool _isTagGroupExpanded = false ;
private bool _isSubmoduleGroupExpanded = false ;
2024-06-27 03:25:16 -07:00
private bool _isWorktreeGroupExpanded = false ;
2024-03-20 20:40:17 -07:00
2024-05-13 20:47:56 -07:00
private string _searchBranchFilter = string . Empty ;
2024-02-05 23:08:37 -08:00
private List < Models . Remote > _remotes = new List < Models . Remote > ( ) ;
private List < Models . Branch > _branches = new List < Models . Branch > ( ) ;
2024-07-24 00:36:26 -07:00
private Models . Branch _currentBranch = null ;
2024-05-13 20:47:56 -07:00
private List < BranchTreeNode > _localBranchTrees = new List < BranchTreeNode > ( ) ;
private List < BranchTreeNode > _remoteBranchTrees = new List < BranchTreeNode > ( ) ;
2024-06-27 03:25:16 -07:00
private List < Models . Worktree > _worktrees = new List < Models . Worktree > ( ) ;
2024-02-05 23:08:37 -08:00
private List < Models . Tag > _tags = new List < Models . Tag > ( ) ;
2024-06-27 06:43:15 -07:00
private List < Models . Tag > _visibleTags = new List < Models . Tag > ( ) ;
2024-08-08 06:11:10 -07:00
private List < Models . Submodule > _submodules = new List < Models . Submodule > ( ) ;
2024-02-05 23:08:37 -08:00
private bool _includeUntracked = true ;
2024-04-01 06:27:08 -07:00
private InProgressContext _inProgressContext = null ;
private bool _hasUnsolvedConflicts = false ;
2024-05-10 01:04:03 -07:00
private Models . Commit _searchResultSelectedCommit = null ;
2024-02-05 23:08:37 -08:00
}
2024-03-31 01:54:29 -07:00
}