-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make repository actions configurable
- Loading branch information
Showing
6 changed files
with
144 additions
and
116 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 was deleted.
Oops, something went wrong.
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,11 @@ | ||
namespace GitMan.Config | ||
{ | ||
internal class ActionSettings | ||
{ | ||
public string Name { get; set; } | ||
public string Program { get; set; } | ||
public string[] Args { get; set; } | ||
public string SearchFilter { get; set; } | ||
public bool? Shell { get; set; } | ||
} | ||
} |
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,92 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
|
||
namespace GitMan.Config | ||
{ | ||
internal static class DefaultActions | ||
{ | ||
public static ActionSettings[] Get() | ||
{ | ||
var actions = new List<ActionSettings>(); | ||
|
||
AddFolderAction(actions); | ||
AddGitBashAction(actions); | ||
AddVsCodeAction(actions); | ||
AddSolutionAction(actions); | ||
|
||
return actions.ToArray(); | ||
} | ||
|
||
private static void AddSolutionAction(List<ActionSettings> actions) | ||
{ | ||
var action = new ActionSettings | ||
{ | ||
Program = "{path}", | ||
Name = "Open {name}", | ||
SearchFilter = "*.sln", | ||
Shell = true, | ||
}; | ||
|
||
actions.Add(action); | ||
} | ||
|
||
private static void AddFolderAction(List<ActionSettings> actions) | ||
{ | ||
var action = new ActionSettings | ||
{ | ||
Program = "{directory}", | ||
Name = "Open folder", | ||
SearchFilter = ".git", | ||
Shell = true, | ||
}; | ||
|
||
actions.Add(action); | ||
} | ||
|
||
private static void AddGitBashAction(List<ActionSettings> actions) | ||
{ | ||
const string gitBashPath = "C:\\Program Files\\Git\\git-bash.exe"; | ||
|
||
var gitBashExists = File.Exists(gitBashPath); | ||
|
||
if (gitBashExists) | ||
{ | ||
var args = new [] { "--cd={directory}" }; | ||
|
||
var action = new ActionSettings | ||
{ | ||
Program = gitBashPath, | ||
Args = args, | ||
Name = "Git Bash", | ||
SearchFilter = ".git", | ||
}; | ||
|
||
actions.Add(action); | ||
} | ||
} | ||
|
||
private static void AddVsCodeAction(List<ActionSettings> actions) | ||
{ | ||
var userProfile = Environment.GetEnvironmentVariable("USERPROFILE"); | ||
var vsCodePath = Path.Combine(userProfile, "AppData\\Local\\Programs\\Microsoft VS Code\\Code.exe"); | ||
|
||
var vsCodeExists = File.Exists(vsCodePath); | ||
|
||
if (vsCodeExists) | ||
{ | ||
var args = new [] { "{directory}" }; | ||
|
||
var action = new ActionSettings | ||
{ | ||
Program = vsCodePath, | ||
Args = args, | ||
Name = "VS Code", | ||
SearchFilter = ".git", | ||
}; | ||
|
||
actions.Add(action); | ||
} | ||
} | ||
} | ||
} |
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