Skip to content
This repository was archived by the owner on Dec 5, 2024. It is now read-only.

Commit 84b7e17

Browse files
Merge branch 'fixes/git-locks-serializable' into features/using-cache-manager
2 parents 034ba9c + af3bf88 commit 84b7e17

File tree

4 files changed

+50
-21
lines changed

4 files changed

+50
-21
lines changed

src/GitHub.Api/Git/GitLock.cs

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,14 @@ namespace GitHub.Unity
55
[Serializable]
66
public struct GitLock
77
{
8-
public static GitLock Default = new GitLock(null, null, null, -1);
9-
10-
public readonly int ID;
11-
public readonly string Path;
12-
public readonly string FullPath;
13-
public readonly string User;
14-
15-
public GitLock(string path, string fullPath, string user, int id)
16-
{
17-
Path = path;
18-
FullPath = fullPath;
19-
User = user;
20-
ID = id;
21-
}
8+
public static GitLock Default = new GitLock {
9+
ID = -1
10+
};
11+
12+
public int ID;
13+
public string Path;
14+
public string FullPath;
15+
public string User;
2216

2317
public override bool Equals(object other)
2418
{

src/GitHub.Api/Git/GitObjectFactory.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,12 @@ public GitLock CreateGitLock(string path, string user, int id)
2626
var npath = new NPath(path).MakeAbsolute();
2727
var fullPath = npath.RelativeTo(environment.RepositoryPath);
2828

29-
return new GitLock(path, fullPath, user, id);
29+
return new GitLock {
30+
Path = path,
31+
FullPath = fullPath,
32+
User = user,
33+
ID = id
34+
};
3035
}
3136
}
3237
}

src/tests/TestUtils/Substitutes/SubstituteFactory.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,12 @@ public IGitObjectFactory CreateGitObjectFactory(string gitRepoPath)
325325
var user = (string)info[1];
326326
var id = (int)info[2];
327327

328-
return new GitLock(path, gitRepoPath + @"\" + path, user, id);
328+
return new GitLock {
329+
Path = path,
330+
FullPath = gitRepoPath + @"\" + path,
331+
User = user,
332+
ID = id
333+
};
329334
});
330335

331336
return gitObjectFactory;

src/tests/UnitTests/IO/LockOutputProcessorTests.cs

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,18 @@ public void ShouldParseTwoLocksFormat1()
6363
};
6464

6565
var expected = new[] {
66-
new GitLock("folder/somefile.png", TestRootPath + @"\folder/somefile.png", "GitHub User", 12),
67-
new GitLock("somezip.zip", TestRootPath + @"\somezip.zip", "GitHub User", 21)
66+
new GitLock {
67+
Path = "folder/somefile.png",
68+
FullPath = TestRootPath + @"\folder/somefile.png",
69+
User = "GitHub User",
70+
ID = 12
71+
},
72+
new GitLock {
73+
Path = "somezip.zip",
74+
FullPath = TestRootPath + @"\somezip.zip",
75+
User = "GitHub User",
76+
ID = 21
77+
}
6878
};
6979

7080
AssertProcessOutput(output, expected);
@@ -81,8 +91,18 @@ public void ShouldParseTwoLocksFormat2()
8191
};
8292

8393
var expected = new[] {
84-
new GitLock("folder/somefile.png", TestRootPath + @"\folder/somefile.png", "GitHub User", 12),
85-
new GitLock("somezip.zip", TestRootPath + @"\somezip.zip", "GitHub User", 21)
94+
new GitLock {
95+
Path = "folder/somefile.png",
96+
FullPath = TestRootPath + @"\folder/somefile.png",
97+
User = "GitHub User",
98+
ID = 12
99+
},
100+
new GitLock {
101+
Path = "somezip.zip",
102+
FullPath = TestRootPath + @"\somezip.zip",
103+
User = "GitHub User",
104+
ID = 21
105+
}
86106
};
87107

88108
AssertProcessOutput(output, expected);
@@ -97,7 +117,12 @@ public void ShouldParseLocksOnFileWithNumericFirstLetter()
97117
};
98118

99119
var expected = new[] {
100-
new GitLock("2_TurtleDoves.jpg", TestRootPath + @"\2_TurtleDoves.jpg", "Tree", 100)
120+
new GitLock {
121+
Path = "2_TurtleDoves.jpg",
122+
FullPath = TestRootPath + @"\2_TurtleDoves.jpg",
123+
User = "Tree",
124+
ID = 100
125+
}
101126
};
102127

103128
AssertProcessOutput(output, expected);

0 commit comments

Comments
 (0)