-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
## [2.4.4] - 2024-07-19 ### Fixed - Fixed the Unity Editor stuck on "Creating workspace" when "Use Unity Version Control" was selected from the Hub
- Loading branch information
Unity Technologies
committed
Jul 19, 2024
1 parent
2bfdef1
commit 8a8323d
Showing
8 changed files
with
68 additions
and
128 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,136 +1,71 @@ | ||
using Codice.Client.Common; | ||
using System; | ||
using Codice.Client.Common; | ||
using Codice.CM.Common; | ||
using PlasticGui; | ||
using Codice.LogWrapper; | ||
using PlasticGui.WorkspaceWindow.Home; | ||
using Unity.PlasticSCM.Editor.Configuration.CloudEdition.Welcome; | ||
using Unity.PlasticSCM.Editor.WebApi; | ||
using UnityEngine; | ||
|
||
namespace Unity.PlasticSCM.Editor.Configuration | ||
{ | ||
internal static class AutoConfig | ||
{ | ||
internal static TokenExchangeResponse PlasticCredentials( | ||
string unityAccessToken, | ||
string serverName, | ||
string wkPath) | ||
string serverName) | ||
{ | ||
SetupUnityEditionToken.CreateCloudEditionTokenIfNeeded(); | ||
SetupUnityEditionToken.CreateCloudEditionToken(); | ||
|
||
bool isClientConfigConfigured = ClientConfig.IsConfigured(); | ||
if (!isClientConfigConfigured) | ||
{ | ||
ConfigureClientConf.FromUnityAccessToken( | ||
unityAccessToken, serverName, wkPath); | ||
} | ||
|
||
TokenExchangeResponse tokenExchangeResponse = WebRestApiClient. | ||
PlasticScm.TokenExchange(unityAccessToken); | ||
|
||
if (tokenExchangeResponse.Error != null) | ||
return tokenExchangeResponse; | ||
var startTick = Environment.TickCount; | ||
|
||
CloudEditionWelcomeWindow.JoinCloudServer( | ||
serverName, | ||
tokenExchangeResponse.User); | ||
|
||
if (!isClientConfigConfigured) | ||
return tokenExchangeResponse; | ||
|
||
ConfigureProfile.ForServerIfNeeded( | ||
serverName, | ||
tokenExchangeResponse.User); | ||
var tokenExchangeResponse = WebRestApiClient.PlasticScm.TokenExchange(unityAccessToken); | ||
|
||
return tokenExchangeResponse; | ||
} | ||
mLog.DebugFormat("TokenExchange time {0} ms", Environment.TickCount - startTick); | ||
|
||
static class ConfigureClientConf | ||
{ | ||
internal static void FromUnityAccessToken( | ||
string unityAccessToken, | ||
string serverName, | ||
string wkPath) | ||
if (tokenExchangeResponse == null) | ||
{ | ||
CredentialsResponse response = WebRestApiClient. | ||
PlasticScm.GetCredentials(unityAccessToken); | ||
|
||
if (response.Error != null) | ||
{ | ||
UnityEngine.Debug.LogErrorFormat( | ||
PlasticLocalization.GetString( | ||
PlasticLocalization.Name.ErrorGettingCredentialsCloudProject), | ||
response.Error.Message, | ||
response.Error.ErrorCode); | ||
|
||
return; | ||
} | ||
|
||
ClientConfigData configData = BuildClientConfigData( | ||
serverName, wkPath, response); | ||
|
||
ClientConfig.Get().Save(configData); | ||
mLog.Warn("Token exchange response null"); | ||
Debug.LogWarning("Token exchange response null"); | ||
return null; | ||
} | ||
|
||
static ClientConfigData BuildClientConfigData( | ||
string serverName, | ||
string wkPath, | ||
CredentialsResponse response) | ||
{ | ||
SEIDWorkingMode workingMode = GetWorkingMode(response.Type); | ||
|
||
ClientConfigData configData = new ClientConfigData(); | ||
|
||
configData.WorkspaceServer = serverName; | ||
configData.CurrentWorkspace = wkPath; | ||
configData.WorkingMode = workingMode.ToString(); | ||
configData.SecurityConfig = UserInfo.GetSecurityConfigStr( | ||
workingMode, | ||
response.Email, | ||
GetPassword(response.Token, response.Type)); | ||
configData.LastRunningEdition = InstalledEdition.Get(); | ||
return configData; | ||
} | ||
|
||
static string GetPassword( | ||
string token, | ||
CredentialsResponse.TokenType tokenType) | ||
if (tokenExchangeResponse.Error != null) | ||
{ | ||
if (tokenType == CredentialsResponse.TokenType.Bearer) | ||
return BEARER_PREFIX + token; | ||
|
||
return token; | ||
var warning = string.Format("Unable to exchange token: {0} [code {1}]", | ||
tokenExchangeResponse.Error.Message, tokenExchangeResponse.Error.ErrorCode); | ||
mLog.ErrorFormat(warning); | ||
Debug.LogWarning(warning); | ||
return tokenExchangeResponse; | ||
} | ||
|
||
static SEIDWorkingMode GetWorkingMode(CredentialsResponse.TokenType tokenType) | ||
if (string.IsNullOrEmpty(tokenExchangeResponse.AccessToken)) | ||
{ | ||
if (tokenType == CredentialsResponse.TokenType.Bearer) | ||
return SEIDWorkingMode.SSOWorkingMode; | ||
|
||
return SEIDWorkingMode.LDAPWorkingMode; | ||
var warning = string.Format("Access token is empty for user: {0}", | ||
tokenExchangeResponse.User); | ||
mLog.InfoFormat(warning); | ||
Debug.LogWarning(warning); | ||
} | ||
|
||
// This creates the client.conf if needed but doesn't overwrite it if it exists already, | ||
// and it also updates the profiles.conf and tokens.conf with the new AccessToken | ||
UserAccounts.SaveAccount( | ||
serverName, | ||
SEIDWorkingMode.SSOWorkingMode, // Hub sign-in working mode | ||
tokenExchangeResponse.User, | ||
tokenExchangeResponse.AccessToken, | ||
null, | ||
null, | ||
null); | ||
|
||
const string BEARER_PREFIX = "Bearer "; | ||
} | ||
|
||
static class ConfigureProfile | ||
{ | ||
internal static void ForServerIfNeeded(string serverName, string user) | ||
{ | ||
ProfileManager profileManager = CmConnection.Get().GetProfileManager(); | ||
|
||
ServerProfile serverProfile = profileManager.GetProfileForServer(serverName); | ||
|
||
if (serverProfile != null) | ||
return; | ||
|
||
serverProfile = ProfileManager.CreateProfile( | ||
serverName, | ||
SEIDWorkingMode.SSOWorkingMode, | ||
user); | ||
CloudEditionWelcomeWindow.JoinCloudServer( | ||
serverName, | ||
tokenExchangeResponse.User); | ||
|
||
profileManager.SaveProfile(serverProfile); | ||
} | ||
return tokenExchangeResponse; | ||
} | ||
|
||
static readonly ILog mLog = PlasticApp.GetLogger("AutoConfig"); | ||
} | ||
|
||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
{ | ||
"name": "com.unity.collab-proxy", | ||
"displayName": "Version Control", | ||
"version": "2.4.3", | ||
"version": "2.4.4", | ||
"unity": "2020.3", | ||
"unityRelease": "48f1", | ||
"description": "The package gives you the ability to use Unity Version Control in the Unity editor. To use Unity Version Control, a subscription is required. Learn more about how you can get started for free by visiting https://unity.com/solutions/version-control", | ||
|
@@ -23,18 +23,18 @@ | |
], | ||
"category": "Editor", | ||
"relatedPackages": { | ||
"com.unity.collab-proxy.tests": "2.4.3" | ||
"com.unity.collab-proxy.tests": "2.4.4" | ||
}, | ||
"_upm": { | ||
"changelog": "### Added\n\n- Changed the default ignore.conf to not ignore itself\n- Added \"Undo unchanged\" and \"Undo checkouts keeping changes\" options to pending changes view\n- Removed focus redirection after Check-in\n\n### Fixed\n\n- Moving folders in the Editor now correctly use the UVCS \"Move\" operation\n- Fixed hang on domain reload \n- Fixed \"item with the same key has already been added\" error\n- Fixed failure to delete a .meta file when deleting a private folder from the pending changes\n- Supported workspace name with non-latin characters in Pending Changes\n- Fixed text cut-off in filter rules dialog\n- Fixed unexpected error while switching between branches\n- Fixed error after renaming a parent branch of the working branch\n- Fixed variables's value becoming clear after resolving conflict in inspector\n- Removed misleading indication about shelves\n- Fixed column sorting in pending changes view\n- Fixed missing incoming changes after removing a branch\n- Fixed \"Collection was modified\" error when doing multiple renames in a row\n- Fixed undo & check-in operations not working when the current scene was never saved\n- Fixed check in error if nothing is selected in the pending changes tree" | ||
"changelog": "### Fixed\n\n- Fixed the Unity Editor stuck on \"Creating workspace\" when \"Use Unity Version Control\" was selected from the Hub" | ||
}, | ||
"upmCi": { | ||
"footprint": "37d231fcc2d5df5d9a23dabe85e2454320fa3a37" | ||
"footprint": "a7e26997432f77ab1e4a2cbf5ba58e4f2f4982ad" | ||
}, | ||
"documentationUrl": "https://docs.unity3d.com/Packages/[email protected]/manual/index.html", | ||
"repository": { | ||
"url": "https://github.cds.internal.unity3d.com/unity/com.unity.cloud.collaborate.git", | ||
"type": "git", | ||
"revision": "d4c8fa70dd9679b33019945dc0a483c8c7e8038f" | ||
"revision": "03b1de8d838eb1e427cb1b1d8bf9157f33377542" | ||
} | ||
} |