Skip to content

Commit f9930f3

Browse files
committed
Create gitignore after initializing repo.
1 parent 0788c97 commit f9930f3

File tree

3 files changed

+49
-0
lines changed

3 files changed

+49
-0
lines changed
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
// Copyright (c) Scott Doxey. All Rights Reserved. Licensed under the MIT License. See LICENSE in the project root for license information.
2+
3+
#if UNITY_EDITOR
4+
using System.IO;
5+
using System.Net;
6+
using System.Threading.Tasks;
7+
8+
namespace CandyCoded.GitStatus
9+
{
10+
11+
public static class GitIgnore
12+
{
13+
14+
private const string URL = "https://raw.githubusercontent.com/github/gitignore/master/Unity.gitignore";
15+
16+
private const string FILENAME = ".gitignore";
17+
18+
public static async Task Create(string directory)
19+
{
20+
21+
var request = WebRequest.Create(URL);
22+
23+
var response = await request.GetResponseAsync();
24+
25+
var content = new MemoryStream();
26+
27+
using (var stream = response.GetResponseStream())
28+
{
29+
30+
await stream.CopyToAsync(content);
31+
32+
File.WriteAllBytes(Path.Combine(directory, FILENAME), content.ToArray());
33+
34+
}
35+
36+
}
37+
38+
}
39+
40+
}
41+
#endif

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

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
#if UNITY_EDITOR
44
using System;
5+
using System.IO;
56
using System.Threading.Tasks;
67
using UnityEditor;
78
using UnityEngine;
@@ -34,6 +35,10 @@ private void OnGUI()
3435

3536
await Git.Init();
3637

38+
await GitIgnore.Create(Directory.GetCurrentDirectory());
39+
40+
GitStatus.Update();
41+
3742
});
3843

3944
}

0 commit comments

Comments
 (0)