-
-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
GitInitializer now handles repository initialization
- Loading branch information
1 parent
bf1fb95
commit 124df94
Showing
24 changed files
with
230 additions
and
165 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
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 |
---|---|---|
|
@@ -31,9 +31,10 @@ public void Setup() | |
injectionHelper.Bind<IGitResourceManager>().To<GitResourceManagerMock>(); | ||
injectionHelper.Bind<ILogger>().FromInstance(Debug.unityLogger); | ||
injectionHelper.Bind<UniGitData>(); | ||
injectionHelper.Bind<GitInitializer>(); | ||
|
||
gitManager = injectionHelper.GetInstance<GitManager>(); | ||
gitManager.InitializeRepository(); | ||
injectionHelper.GetInstance<GitInitializer>().InitializeRepository(); | ||
gitCallbacks = injectionHelper.GetInstance<GitCallbacks>(); | ||
signature = new Signature("Test", "[email protected]", DateTime.Now); | ||
data = injectionHelper.GetInstance<UniGitData>(); | ||
|
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
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 |
---|---|---|
@@ -0,0 +1,85 @@ | ||
using System.IO; | ||
using System.Linq; | ||
using LibGit2Sharp; | ||
using UniGit.Utils; | ||
using UnityEditor; | ||
using UnityEngine; | ||
|
||
namespace UniGit | ||
{ | ||
public class GitInitializer | ||
{ | ||
private readonly string repoPath; | ||
private readonly string gitPath; | ||
private readonly ILogger logger; | ||
private readonly GitCallbacks callbacks; | ||
|
||
[UniGitInject] | ||
public GitInitializer(string repoPath,ILogger logger,GitCallbacks callbacks) | ||
{ | ||
this.repoPath = repoPath; | ||
this.logger = logger; | ||
this.callbacks = callbacks; | ||
gitPath = UniGitPath.Combine(repoPath, ".git"); | ||
} | ||
|
||
public void InitializeRepository() | ||
{ | ||
Repository.Init(repoPath); | ||
Directory.CreateDirectory(GitSettingsFolderPath); | ||
string newGitIgnoreFile = GitIgnoreFilePath; | ||
if (!File.Exists(newGitIgnoreFile)) | ||
{ | ||
File.WriteAllText(newGitIgnoreFile, GitIgnoreTemplate.Template); | ||
} | ||
else | ||
{ | ||
logger.Log(LogType.Log,"Git Ignore file already present"); | ||
} | ||
|
||
logger.Log(LogType.Log,"Repository Initialized"); | ||
//Initialize(); | ||
} | ||
|
||
internal void InitializeRepositoryAndRecompile() | ||
{ | ||
InitializeRepository(); | ||
callbacks.IssueAssetDatabaseRefresh(); | ||
callbacks.IssueSaveDatabaseRefresh(); | ||
callbacks.IssueRepositoryCreate(); | ||
//Update(true); | ||
} | ||
|
||
internal static void Recompile() | ||
{ | ||
var importer = PluginImporter.GetAllImporters().FirstOrDefault(i => i.assetPath.EndsWith("UniGitResources.dll")); | ||
if (importer == null) | ||
{ | ||
Debug.LogError("Could not find LibGit2Sharp.dll. You will have to close and open Unity to recompile scripts."); | ||
return; | ||
} | ||
importer.SetCompatibleWithEditor(true); | ||
importer.SaveAndReimport(); | ||
} | ||
|
||
public bool IsValidRepo | ||
{ | ||
get { return Repository.IsValid(repoPath); } | ||
} | ||
|
||
public string GitSettingsFolderPath | ||
{ | ||
get { return UniGitPath.Combine(gitPath, Path.Combine("UniGit", "Settings")); } | ||
} | ||
|
||
public string GitCommitMessageFilePath | ||
{ | ||
get { return UniGitPath.Combine(gitPath, "UniGit","Settings", "CommitMessage.txt"); } | ||
} | ||
|
||
public string GitIgnoreFilePath | ||
{ | ||
get { return UniGitPath.Combine(repoPath, ".gitignore"); } | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.