private static bool UpdateVCSInfo(CocoVCSInfo vcsInfo, string output) { bool changed = false; // commit id string commitId = output.Substring(0, COMMIT_ID_LENGTH); if (!string.Equals(commitId, vcsInfo.CommitId)) { vcsInfo.CommitId = commitId; changed = true; } // load time try { string loadTime = DateTime.UtcNow.ToString(CocoVCSInfoDisplayer.INFO_TIME_FORMAT, CultureInfo.InvariantCulture); if (!string.Equals(loadTime, vcsInfo.LoadTime)) { vcsInfo.LoadTime = loadTime; changed = true; } } catch (Exception e) { Debug.LogErrorFormat("CocoVCSInfoRecorder->UpdateVCSInfo: load time read error! [{0}]", e.Message); } return(changed); }
private static CocoVCSInfo LoadVCSInfo(string path) { CocoVCSInfo vcsInfo = new CocoVCSInfo(); if (File.Exists(path)) { string json = File.ReadAllText(path); JsonUtility.FromJsonOverwrite(json, vcsInfo); } return(vcsInfo); }
private IEnumerator LoadVCSInfoAsync() { string path = LocalPathProtocolHeader + InfoFilePath; using (WWW www = new WWW(path)) { _loadStatus = LoadStatus.Loading; yield return(www); if (!string.IsNullOrEmpty(www.error)) { Debug.LogWarningFormat("{0}->LoadVCSInfoAsync: load vcs info FAILED! [{1}]", GetType().Name, www.error); yield break; } _vcsInfo = JsonUtility.FromJson <CocoVCSInfo> (www.text); _loadStatus = _vcsInfo != null && !string.IsNullOrEmpty(_vcsInfo.CommitId) ? LoadStatus.Loaded : LoadStatus.LoadFailed; } }
private static void SaveVCSInfo(CocoVCSInfo vcsInfo, string path) { string json = JsonUtility.ToJson(vcsInfo); string directory = Path.GetDirectoryName(path); if (string.IsNullOrEmpty(directory)) { return; } if (!Directory.Exists(directory)) { Directory.CreateDirectory(directory); } if (File.Exists(path)) { File.Delete(path); } File.WriteAllText(path, json); Debug.Log("vcs info saved: " + json); }
private static void RecordVCSInfo() { if (EditorApplication.isPlayingOrWillChangePlaymode) { return; } string output = ObtainVCSInfo(); string path = CocoVCSInfoDisplayer.InfoFilePath; CocoVCSInfo vcsInfo = LoadVCSInfo(path); bool changed = UpdateVCSInfo(vcsInfo, output); if (!changed) { return; } SaveVCSInfo(vcsInfo, path); AssetDatabase.Refresh(); }