Skip to content

Commit 526ab91

Browse files
committed
Added LockedFiles method.
1 parent 61ee007 commit 526ab91

File tree

3 files changed

+83
-1
lines changed

3 files changed

+83
-1
lines changed

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

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
using System.Diagnostics;
77
using System.IO;
88
using System.Threading.Tasks;
9+
using UnityEngine;
910

1011
namespace CandyCoded.GitStatus
1112
{
@@ -15,8 +16,12 @@ public static class Git
1516

1617
#if UNITY_EDITOR_WIN
1718
private static string GitPath => @"C:\Program Files\Git\bin\git.exe";
19+
20+
public static string GitLFSPath => @"C:\Program Files\Git LFS\git-lfs.exe";
1821
#else
19-
private static string GitPath => "/usr/local/bin/git";
22+
public static string GitPath => "/usr/local/bin/git";
23+
24+
public static string GitLFSPath => "/usr/local/bin/git-lfs";
2025
#endif
2126

2227
private static string RepoPath => $"{Environment.CurrentDirectory}{Path.DirectorySeparatorChar}";
@@ -117,6 +122,33 @@ public static async Task Init()
117122

118123
}
119124

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

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)