Skip to content

Commit fb61b9b

Browse files
committed
Added LockedFiles method.
1 parent f609338 commit fb61b9b

File tree

3 files changed

+82
-0
lines changed

3 files changed

+82
-0
lines changed

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

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
using System.Collections.Generic;
66
using System.Diagnostics;
77
using System.Threading.Tasks;
8+
using UnityEngine;
89

910
namespace CandyCoded.GitStatus
1011
{
@@ -14,8 +15,12 @@ public static class Git
1415

1516
#if UNITY_EDITOR_WIN
1617
public static string GitPath => "C:\\Program Files\\Git\\cmd\\git.exe";
18+
19+
public static string GitLFSPath => "C:\\Program Files\\Git LFS\\git-lfs.exe";
1720
#else
1821
public static string GitPath => "/usr/local/bin/git";
22+
23+
public static string GitLFSPath => "/usr/local/bin/git-lfs";
1924
#endif
2025

2126
private static Process GenerateProcess(string path, string arguments)
@@ -113,6 +118,33 @@ public static async Task Init()
113118

114119
}
115120

121+
public static async Task<string[]> LockedFiles()
122+
{
123+
124+
var process = await GenerateProcessAsync(GitLFSPath, "locks --json");
125+
126+
process?.WaitForExit();
127+
128+
var locked = new List<string>();
129+
130+
var locks = JsonUtility.FromJson<Locks>($@"{{""locks"":{process?.StandardOutput.ReadToEnd()}}}").locks;
131+
132+
if (locks != null)
133+
{
134+
135+
for (var i = 0; i < locks.Length; i += 1)
136+
{
137+
138+
locked.Add(locks[i].path);
139+
140+
}
141+
142+
}
143+
144+
return locked.ToArray();
145+
146+
}
147+
116148
public static async Task<string> Status()
117149
{
118150

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
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;
5+
6+
namespace CandyCoded.GitStatus
7+
{
8+
9+
public struct Locks
10+
{
11+
12+
public Lock[] locks;
13+
14+
}
15+
16+
[Serializable]
17+
public struct Lock
18+
{
19+
20+
[Serializable]
21+
public struct Owner
22+
{
23+
24+
public string name;
25+
26+
}
27+
28+
public long id;
29+
30+
public string path;
31+
32+
public Owner owner;
33+
34+
public string locked_at;
35+
36+
}
37+
38+
}
39+
#endif

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

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

0 commit comments

Comments
 (0)