Skip to content

Commit 0788c97

Browse files
committed
Add button for creating a git repo if one doesn't exist.
1 parent c49a82e commit 0788c97

File tree

2 files changed

+40
-0
lines changed

2 files changed

+40
-0
lines changed

Assets/Plugins/CandyCoded.GitStatus/Scripts/CustomEditor/GitStatus.cs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ namespace CandyCoded.GitStatus
1212
public static class GitStatus
1313
{
1414

15+
public static bool isGitRepo;
16+
17+
public static string status = "";
18+
1519
public static string branch = "HEAD";
1620

1721
public static string[] branches = { };
@@ -42,6 +46,23 @@ public static void Update()
4246
public static async void UpdateAsync()
4347
{
4448

49+
try
50+
{
51+
52+
status = await Git.Status();
53+
54+
isGitRepo = true;
55+
56+
}
57+
catch (Exception error)
58+
{
59+
60+
status = error.Message;
61+
62+
isGitRepo = false;
63+
64+
}
65+
4566
branch = await Git.Branch();
4667
branches = await Git.Branches();
4768
changedFiles = await Git.ChangedFiles();

Assets/Plugins/CandyCoded.GitStatus/Scripts/CustomEditor/GitStatusPanel.cs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,25 @@ public static void ShowWindow()
2323
private void OnGUI()
2424
{
2525

26+
if (!GitStatus.isGitRepo)
27+
{
28+
29+
if (GUILayout.Button("Initialize git repo"))
30+
{
31+
32+
Task.Run(async () =>
33+
{
34+
35+
await Git.Init();
36+
37+
});
38+
39+
}
40+
41+
return;
42+
43+
}
44+
2645
GUILayout.Space(5);
2746

2847
var selectedBranch = Array.IndexOf(GitStatus.branches, GitStatus.branch);

0 commit comments

Comments
 (0)