-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feature: Added support for initializing folders as Git repos (#12803)
- Loading branch information
1 parent
7f14d5e
commit 25b0155
Showing
10 changed files
with
80 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
// Copyright (c) 2023 Files Community | ||
// Licensed under the MIT License. See the LICENSE. | ||
|
||
using Files.App.Contexts; | ||
|
||
namespace Files.App.Actions | ||
{ | ||
sealed class GitInitAction : ObservableObject, IAction | ||
{ | ||
private readonly IContentPageContext _context; | ||
|
||
public string Label | ||
=> "InitRepo".GetLocalizedResource(); | ||
|
||
public string Description | ||
=> "InitRepoDescription".GetLocalizedResource(); | ||
|
||
public bool IsExecutable => | ||
_context.Folder is not null && | ||
!_context.IsGitRepository; | ||
|
||
public GitInitAction() | ||
{ | ||
_context = Ioc.Default.GetRequiredService<IContentPageContext>(); | ||
|
||
_context.PropertyChanged += Context_PropertyChanged; | ||
} | ||
|
||
public Task ExecuteAsync() | ||
{ | ||
GitHelpers.InitializeRepository(_context.Folder?.ItemPath); | ||
return Task.CompletedTask; | ||
} | ||
|
||
private void Context_PropertyChanged(object? sender, PropertyChangedEventArgs e) | ||
{ | ||
switch (e.PropertyName) | ||
{ | ||
case nameof(IContentPageContext.Folder): | ||
case nameof(IContentPageContext.IsGitRepository): | ||
OnPropertyChanged(nameof(IsExecutable)); | ||
break; | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -182,6 +182,7 @@ public enum CommandCodes | |
|
||
// Git | ||
GitFetch, | ||
GitInit, | ||
GitPull, | ||
GitPush, | ||
GitSync, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters