Skip to content

Commit 8fb5c1e

Browse files
committed
Workaround for Unity VersionControl.Provider.Checkout() regression
According to the user, calling VersionControl.Provider.Checkout( string, CheckoutMode) may throw exception in certain version of Unity due to Unity regression, while VersionControl.Provider.Checkout( AssetList, CheckoutMode) works properly. Fixed #359 Bug: 154264996 Change-Id: I011595274dbb83d202f6b0bf461de530f6f802ed Change-Id: I5970acab818195d3ce721c4a7978fb935cae43cd
1 parent 2f27005 commit 8fb5c1e

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

source/VersionHandlerImpl/src/FileUtils.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -326,14 +326,19 @@ public static bool CheckoutFile(string path, Logger logger) {
326326
(!UnityEditor.VersionControl.Provider.requiresNetwork ||
327327
UnityEditor.VersionControl.Provider.onlineState ==
328328
UnityEditor.VersionControl.OnlineState.Online)) {
329+
330+
// Some versions of Unity seem to have bug to convert "string path" to
331+
// "AssetList assets" (See #359). Generate it in advance as a workaround.
332+
var assetList = new UnityEditor.VersionControl.AssetList();
333+
assetList.Add(new UnityEditor.VersionControl.Asset(path));
329334
// Unity 2019.1+ broke backwards compatibility of Checkout() by adding an
330335
// optional argument to the method so we dynamically invoke the method to add
331336
// the optional
332337
// argument for the Unity 2019.1+ overload at runtime.
333338
var task = (UnityEditor.VersionControl.Task)VersionHandler.InvokeStaticMethod(
334339
typeof(UnityEditor.VersionControl.Provider),
335340
"Checkout",
336-
new object[] { path, UnityEditor.VersionControl.CheckoutMode.Exact },
341+
new object[] { assetList, UnityEditor.VersionControl.CheckoutMode.Exact },
337342
namedArgs: null);
338343
task.Wait();
339344
if (!task.success) {

0 commit comments

Comments
 (0)