mirror of
https://fastgit.cc/github.com/sourcegit-scm/sourcegit
synced 2026-04-30 13:51:53 +08:00
feature: supports to exclude some editors (#2033)
Signed-off-by: leo <longshuang@msn.cn>
This commit is contained in:
12
README.md
12
README.md
@@ -176,13 +176,19 @@ This app supports open repository in external tools listed in the table below.
|
||||
| Visual Studio | YES | NO | NO |
|
||||
|
||||
> [!NOTE]
|
||||
> This app will try to find those tools based on some pre-defined or expected locations automatically. If you are using one portable version of these tools, it will not be detected by this app.
|
||||
> To solve this problem you can add a file named `external_editors.json` in app data storage directory and provide the path directly. For example:
|
||||
> This app will try to find those tools based on some pre-defined or expected locations automatically. If you are using one portable version of these tools, it will not be detected by this app.
|
||||
> To solve this problem you can add a file named `external_editors.json` in app data storage directory and provide the path directly.
|
||||
> User can also exclude some editors by using `external_editors.json`.
|
||||
|
||||
The format of `external_editors.json`:
|
||||
```json
|
||||
{
|
||||
"tools": {
|
||||
"Visual Studio Code": "D:\\VSCode\\Code.exe"
|
||||
}
|
||||
},
|
||||
"excludes": [
|
||||
"Visual Studio Community 2019"
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
@@ -59,7 +59,7 @@ namespace SourceGit
|
||||
typeof(DataGridLengthConverter),
|
||||
]
|
||||
)]
|
||||
[JsonSerializable(typeof(Models.ExternalToolPaths))]
|
||||
[JsonSerializable(typeof(Models.ExternalToolCustomization))]
|
||||
[JsonSerializable(typeof(Models.HistoryFilterCollection))]
|
||||
[JsonSerializable(typeof(Models.InteractiveRebaseJobCollection))]
|
||||
[JsonSerializable(typeof(Models.JetBrainsState))]
|
||||
|
||||
@@ -95,10 +95,12 @@ namespace SourceGit.Models
|
||||
public string LaunchCommand { get; set; }
|
||||
}
|
||||
|
||||
public class ExternalToolPaths
|
||||
public class ExternalToolCustomization
|
||||
{
|
||||
[JsonPropertyName("tools")]
|
||||
public Dictionary<string, string> Tools { get; set; } = new Dictionary<string, string>();
|
||||
[JsonPropertyName("excludes")]
|
||||
public List<string> Excludes { get; set; } = new List<string>();
|
||||
}
|
||||
|
||||
public class ExternalToolsFinder
|
||||
@@ -117,7 +119,7 @@ namespace SourceGit.Models
|
||||
if (File.Exists(customPathsConfig))
|
||||
{
|
||||
using var stream = File.OpenRead(customPathsConfig);
|
||||
_customPaths = JsonSerializer.Deserialize(stream, JsonCodeGen.Default.ExternalToolPaths);
|
||||
_customization = JsonSerializer.Deserialize(stream, JsonCodeGen.Default.ExternalToolCustomization);
|
||||
}
|
||||
}
|
||||
catch
|
||||
@@ -125,12 +127,15 @@ namespace SourceGit.Models
|
||||
// Ignore
|
||||
}
|
||||
|
||||
_customPaths ??= new ExternalToolPaths();
|
||||
_customization ??= new ExternalToolCustomization();
|
||||
}
|
||||
|
||||
public void TryAdd(string name, string icon, Func<string> finder, Func<string, string> execArgsGenerator = null)
|
||||
{
|
||||
if (_customPaths.Tools.TryGetValue(name, out var customPath) && File.Exists(customPath))
|
||||
if (_customization.Excludes.Contains(name))
|
||||
return;
|
||||
|
||||
if (_customization.Tools.TryGetValue(name, out var customPath) && File.Exists(customPath))
|
||||
{
|
||||
Tools.Add(new ExternalTool(name, icon, customPath, execArgsGenerator));
|
||||
}
|
||||
@@ -201,6 +206,6 @@ namespace SourceGit.Models
|
||||
}
|
||||
}
|
||||
|
||||
private ExternalToolPaths _customPaths = null;
|
||||
private ExternalToolCustomization _customization = null;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user