Forest_Client/Forest/Assets/PhxhSDK/Editor/VersionControlSystem.cs

180 lines
5.6 KiB
C#

// using UnityEditor.VersionControl;
// using UnityEditor;
// using System.IO;
// using UnityEngine;
//
// public class VersionControlSystem
// {
// public static void Add(string path)
// {
// //if (!File.Exists(path))
// //{
// // Debug.LogError(" Failed to Add , File does not exist: " + path);
// // return;
// //}
// //if (Provider.onlineState != OnlineState.Online )
// //{
// // Debug.LogError($"PerfoceState :{Provider.onlineState}, Failed to connect to Perforce server.");
// // return;
// //}
// //AssetList assets = new AssetList();
// //assets.Add(Provider.GetAssetByPath(path));
// //Task t = Provider.Add(assets, recursive: false);
// //t.Wait();
//
// //if (!t.success)
// //{
// // Debug.LogError($"Failed to add file. ");
// // return;
// //}
// //AssetDatabase.Refresh();
// }
//
// public static void Delete(string path)
// {
// //if (!File.Exists(path))
// //{
// // Debug.LogError(" Failed to Delete , File does not exist: " + path);
// // return;
// //}
//
// //if (Provider.onlineState != OnlineState.Online)
// //{
// // Debug.LogError($"PerfoceState :{Provider.onlineState}, Failed to connect to Perforce server.");
// // return;
// //}
// //AssetList assets = new AssetList();
// //assets.Add(Provider.GetAssetByPath(path));
// //assets.Add(Provider.GetAssetByPath(path + ".meta"));
// //Task t = Provider.Delete(assets);
// //t.Wait();
//
// //if (!t.success)
// //{
// // Debug.LogError($"Failed to delete file: {t.text}");
// // return;
// //}
// //AssetDatabase.Refresh();
// }
//
// public static void Checkout(string path)
// {
// //if (Provider.onlineState != OnlineState.Online)
// //{
// // Debug.LogError($"PerfoceState :{Provider.onlineState}, Failed to connect to Perforce server.");
// // return;
// //}
// //AssetList assets = new AssetList();
// //var asset = Provider.GetAssetByPath(path);
// //if (asset != null)
// //{
// // assets.Add(asset);
// //}
//
// //Task t;
// //if (assets.Count > 0)
// //{
// // t = Provider.Checkout(assets, CheckoutMode.Both);
// // t.Wait();
// //}
// //else
// //{
// // t = Provider.Checkout(path, CheckoutMode.Both);
// // t.Wait();
// //}
//
// //if (!t.success)
// //{
// // Debug.LogError($"Failed to checkout file, Try again.");
// // return;
// //}
// //AssetDatabase.Refresh();
// }
//
// public static void Revert(string path, RevertMode revertMode = RevertMode.Normal)
// {
// //if (Provider.onlineState != OnlineState.Online)
// //{
// // Debug.LogError($"PerfoceState :{Provider.onlineState}, Failed to connect to Perforce server.");
// // return;
// //}
// //AssetList assets = new AssetList();
// //var asset = Provider.GetAssetByPath(path);
// //if (asset != null)
// //{
// // assets.Add(asset);
// //}
//
// //if (assets.Count > 0)
// //{
// // Task t = Provider.Revert(assets, revertMode);
// // t.Wait();
// // if (!t.success)
// // {
// // Debug.LogError($"Failed to revert file: {path}");
// // return;
// // }
// //}
// //else
// //{
// // Debug.LogError($"revert cannot find asset : {path}");
// // return;
// //}
// //AssetDatabase.Refresh();
// }
//
// public static void Submit(string path, string des)
// {
// //if (Provider.onlineState != OnlineState.Online)
// //{
// // Debug.LogError($"PerfoceState :{Provider.onlineState}, Failed to connect to Perforce server.");
// // return;
// //}
// //AssetList assets = new AssetList();
// //assets.Add(Provider.GetAssetByPath(path));
// //Task t = Provider.Submit(new ChangeSet(), assets, des, saveOnly: false);
// //t.Wait();
//
// //if (!t.success)
// //{
// // Debug.LogError($"Failed to submit file");
// // return;
// //}
// //AssetDatabase.Refresh();
// }
//
//
// public static void GetLast()
// {
// //if (Provider.onlineState != OnlineState.Online)
// //{
// // Debug.LogError($"PerfoceState :{Provider.onlineState}, Failed to connect to Perforce server.");
// // return;
// //}
//
// //string assetsFolderPath = "Assets";
//
// //Asset asset = Provider.GetAssetByPath(assetsFolderPath);
// //if (asset == null)
// //{
// // Debug.LogError("Failed to get Asset object for the 'Assets' folder.");
// // return;
// //}
//
// //Task t = Provider.GetLatest(asset);
// //t.Wait();
//
// //if (t.success)
// //{
// // DebugUtil.Log("Successfully pulled latest code and assets.");
// //}
// //else
// //{
// // DebugUtil.LogError("Failed to pull latest code and assets.");
// //}
//
// //AssetDatabase.Refresh();
// }
// }