-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e4ac1ec
commit 93496f5
Showing
3 changed files
with
18 additions
and
37 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
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 |
---|---|---|
|
@@ -10,9 +10,9 @@ static class VSCode | |
{ | ||
private static readonly string ico = "Prompt.png"; | ||
|
||
public static void openResultInVSCode(ApiResultRepo result, SettingsModel settings) | ||
public static void openResultInVSCode(string result) | ||
{ | ||
openVSCode($"{settings.gitFolder}\\{result.name}"); | ||
openVSCode(result); | ||
} | ||
|
||
public static void openVSCode(String folder) | ||
|
@@ -32,29 +32,6 @@ public static void openVSCode(String folder) | |
Process.Start(info); | ||
} | ||
|
||
public static void cloneRepo(ApiResultRepo result, SettingsModel settings) | ||
{ | ||
if (Directory.Exists($"{settings.gitFolder}\\{result.name}")) | ||
{ | ||
return; | ||
} | ||
var cloneUrl = $"[email protected]:{result.owner.login}/{result.name}.git"; | ||
var command = $"git clone {cloneUrl}"; | ||
|
||
ProcessStartInfo info; | ||
var arguments = $"/c \"{command}\""; | ||
info = new ProcessStartInfo | ||
{ | ||
FileName = "cmd.exe", | ||
Arguments = arguments, | ||
UseShellExecute = true, | ||
WindowStyle = ProcessWindowStyle.Hidden, | ||
WorkingDirectory = settings.gitFolder | ||
}; | ||
|
||
Process.Start(info); | ||
} | ||
|
||
public static List<Result> Query(Query query, SettingsModel settings, PluginInitContext context) | ||
{ | ||
List<Result> list = new List<Result>(); | ||
|
@@ -75,21 +52,19 @@ public static List<Result> Query(Query query, SettingsModel settings, PluginInit | |
return list; | ||
} | ||
|
||
ApiResult results = GithubApi.QueryGithub(query, settings); | ||
string[] results = Directory.GetDirectories(settings.gitFolder, $"*{query.Search}*", SearchOption.TopDirectoryOnly); | ||
|
||
if (results.total_count > 0) | ||
if (results.Length > 0) | ||
{ | ||
foreach (ApiResultRepo result in results.items) | ||
foreach (string result in results) | ||
{ | ||
list.Add(new Result | ||
{ | ||
Title = result.full_name, | ||
SubTitle = result.description, | ||
Title = Path.GetFileName(result), | ||
IcoPath = ico, | ||
Action = (e) => | ||
{ | ||
cloneRepo(result, settings); | ||
openResultInVSCode(result, settings); | ||
openResultInVSCode(result); | ||
return true; | ||
} | ||
}); | ||
|