public void saveConfig( Console console ) { FileInfo info = null; UnityThreadHelper.CreateThread( () => { try { info = new FileInfo( configPath ); info.Delete(); } catch ( System.Exception e ) { Debug.Log( e ); } try { StreamWriter writer = new StreamWriter( configPath ); writer.WriteLine( username.Trim() ); writer.WriteLine( password.Trim() ); if ( explicitPathToRepository != null ) { writer.WriteLine( explicitPathToRepository.Trim() ); } writer.Close(); console.credentials = new Credentials(); console.credentials.Username = username.Trim(); console.credentials.Password = password.Trim(); } catch ( System.Exception e ) { Debug.Log( e ); } } ); }
public ConfigManager( Console console ) { dataPath = Application.dataPath; configPath = dataPath + "\\Git UniTEAM\\Editor\\git-uniteam-config.txt"; loadConfig( console ); }
public void draw( Console console, int id ) { scroll = GUILayout.BeginScrollView( scroll ); foreach ( Commit commit in console.repo.Commits.QueryBy( new Filter { Since = console.branch.TrackedBranch, Until = console.branch.Tip } ) ) { console.getUpdateItem( commit, commit.Parents.First(), rect, onCommitSelected ); } GUILayout.EndScrollView(); }
public static void RemoteFetch( Remote remote, Credentials creds, Console console ) { try { remote.Fetch( TagFetchMode.Auto, OnProgress, OnCompletion, OnUpdateTips, OnTransferProgress, credentials: creds ); } catch ( System.Exception e ) { Debug.Log( e ); } }
public void draw( Console console, int i ) { pathNodes.Clear(); treeView.nodes.Clear(); scroll = GUILayout.BeginScrollView( scroll ); if ( changes != null ) { foreach ( TreeEntryChanges change in changes ) { buildTreeView( change ); } } drawTreeView(); GUILayout.EndScrollView(); }
public void draw( Console console, int id ) { GUILayout.Label( "Repository: " + console.repo.Info.WorkingDirectory ); GUILayout.Label( "Current branch: " + console.branch.Name ); GUILayout.Label( "" ); GUILayout.Label( "HTTP/HTTPS Credentials" ); GUILayout.Label( "Username (if required)" ); console.configManager.username = GUILayout.TextField( console.configManager.username ); GUILayout.Label( "Password (if required)" ); console.configManager.password = GUILayout.PasswordField( console.configManager.password, "*".ToCharArray()[ 0 ] ); if ( GUILayout.Button( "Save" ) ) { console.configManager.saveConfig( console ); } }
private void getRemoteList( Console console ) { GUILayout.BeginVertical( "Box" ); if ( GUILayout.Button( selectedRemote ) ) { isSelecting = !isSelecting; } if ( isSelecting ) { int i = 0; foreach ( Remote b in console.repo.Network.Remotes ) { if ( GUI.Button( new Rect( 0, 30 + ( i * 30 ), 20, 20 ), b.Name ) ) { selectedRemote = b.Name; isSelecting = false; } i++; } } GUILayout.EndHorizontal(); }
private void loadConfig( Console console ) { try { StreamReader reader = new StreamReader( configPath ); username = reader.ReadLine().Trim(); password = reader.ReadLine().Trim(); //# Test for real path defined... string readLine = reader.ReadLine(); if ( readLine != null ) { explicitPathToRepository = readLine.Trim(); } reader.Close(); console.credentials = new Credentials(); console.credentials.Username = username.Trim(); console.credentials.Password = password.Trim(); } catch ( System.Exception ) { } }
public void reset( TreeChanges newChanges, Console console ) { changes = newChanges; treeView = new TreeView(); }
private void OnGUI() { if ( !hasClosedConsole ) { hasClosedConsole = true; cns.Close(); cns = null; } if ( wordWrapLabelStyle == null ) { wordWrapLabelStyle = new GUIStyle( GUI.skin.label ); textAreaStyle = new GUIStyle( GUI.skin.textArea ); wordWrapLabelStyle.wordWrap = true; } switch ( setupState ) { case SetupState.nothing: GUILayout.Label( "This Unity project is not currently under version control." ); GUILayout.Label( "" ); GUILayout.Label( "Would you like to 'Clone' a remote repository, or 'Initialize' your current project for Git version control?" ); GUILayout.Label( "" ); GUILayout.BeginHorizontal(); GUI.enabled = !( setupState == SetupState.clone ); if ( GUILayout.Button( "Clone" ) ) { setupState = SetupState.clone; } GUI.enabled = false; if ( GUILayout.Button( "Initialize [NOT YET IMPLEMENTED]" ) ) { setupState = SetupState.initialize; } GUI.enabled = true; GUILayout.EndHorizontal(); break; case SetupState.clone: drawGetRemoteCredentials(); GUILayout.Label( "" ); GUILayout.Label( "WARNING!" ); GUILayout.Label( "1 ) Any conflicting files in this project directory [" + tempDir + "] will be OVERWRITTEN by the ones one the server. " + "Back them up if you value them.", wordWrapLabelStyle, GUILayout.Width( 400 ) ); GUILayout.Label( "" ); GUILayout.Label( "2 ) If the remote repository has 'Git UniTEAM' under version control, the clone will fail since the .dll " + "files are currently in use by Unity; you'll have to close Unity, and clone the repository using another tool, " + "such as TortoiseGit. Data loss may occur if you do not heed / investigate this warning!", wordWrapLabelStyle, GUILayout.Width( 400 ) ); GUILayout.Label( "" ); if ( GUILayout.Button( "I understand; Start Clone" ) ) { setupState = SetupState.working; EditorApplication.LockReloadAssemblies(); clone(); } if ( GUILayout.Button( "Cancel" ) ) { setupState = SetupState.nothing; } break; case SetupState.initialize: break; case SetupState.working: GUILayout.Label( "Work log:" ); try { scroll = GUILayout.BeginScrollView( ( hasWorkError ) ? scroll : new Vector2( 0, int.MaxValue ), textAreaStyle, GUILayout.Height( 200 ) ); EditorGUILayout.TextArea( string.Join( "\r\n", progressInfo.ToArray() ) ); }catch{} GUILayout.EndScrollView(); if ( hasWorkError ) { if ( GUILayout.Button( "Retry failed operation." ) ) { progressInfo.Clear(); hasWorkError = false; Directory.Delete( tempDir, true ); EditorApplication.LockReloadAssemblies(); clone(); } } break; case SetupState.complete: EditorApplication.UnlockReloadAssemblies(); GUILayout.Label( "All work complete. Please click the close button." ); if ( GUILayout.Button( "Close, and restart console." ) ) { Console.init(); this.Close(); } break; } }
public void draw( Console console, int i ) { scroll = GUILayout.BeginScrollView( scroll ); try { pathNodes.Clear(); treeView.nodes.Clear(); changes = changes ?? console.repo.Diff.Compare(); foreach ( TreeEntryChanges change in changes ) { buildTreeView( change ); } foreach ( string untrackedFile in untracked ) { buildTreeView( untrackedFile ); } drawTreeView( console ); } catch {} GUILayout.EndScrollView(); GUILayout.Label( "Commit message:" ); commitText = GUILayout.TextArea( commitText ); if ( GUILayout.Button( "Commit Changes" ) ) { Signature signature = new Signature( "Jerome Doby", "*****@*****.**", System.DateTimeOffset.Now ); //# Stage everything string[] stage = new string[ checkboxValues.Count ]; i = 0; foreach ( KeyValuePair<string, bool> pair in checkboxValues ) { if ( pair.Value ) { stage[ i ] = pair.Key; i++; } } stage = stage.Where( x => !string.IsNullOrEmpty( x ) ).ToArray(); if ( stage.Length == 0 ) { console.currentError = "You cannot commit without staged items."; console.currentErrorLocation = rect; } else if ( commitText.Equals( string.Empty ) ) { console.currentError = "Please enter a commit message."; console.currentErrorLocation = rect; } else { console.repo.Index.Stage( stage ); console.repo.Commit( commitText, signature ); checkboxValues.Clear(); foldoutValues.Clear(); console.fetch(); } commitText = string.Empty; } }
public void reset( TreeChanges newChanges, Console console ) { changes = newChanges; untracked = console.repo.Index.RetrieveStatus().Untracked; treeView = new TreeView(); }
private void drawTreeView( Console console ) { //# Loop through each node (folder) foreach ( KeyValuePair<string, TreeViewNode> treeViewNode in treeView.nodes ) { //# Add a foldup entry if there isn't already one if ( !foldoutValues.ContainsKey( treeViewNode.Value.name ) ) { foldoutValues.Add( treeViewNode.Value.name, true ); } EditorGUILayout.BeginHorizontal( highlightStyle ); foldoutValues[ treeViewNode.Value.name ] = EditorGUILayout.Foldout( foldoutValues[ treeViewNode.Value.name ], treeViewNode.Value.name ); if ( treeViewNode.Value.items.All( delegate( TreeViewItem item ) { return item.status.Equals( "Untracked" ); } ) ) { if ( GUILayout.Button( "Ignore", buttonStyle, GUILayout.Width( 50 ) ) ) { console.repo.Ignore.AddPermanentRules( new string[] { treeViewNode.Value.name } ); } } EditorGUILayout.EndHorizontal(); //# If the foldup is folded, then just continue to the next iteration and don't show children if ( !foldoutValues[ treeViewNode.Value.name ] ) { continue; } //# Loop through each actual file in this node foreach ( TreeViewItem treeViewItem in treeViewNode.Value.items ) { //# Add checkbox entry if not already there. Untracked files are unchecked by default. if ( !checkboxValues.ContainsKey( treeViewItem.path ) ) { checkboxValues.Add( treeViewItem.path, !treeViewItem.status.Equals( "Untracked" ) ); } EditorGUILayout.BeginHorizontal( noStyle ); GUILayout.Space( 15f ); checkboxValues[ treeViewItem.path ] = GUILayout.Toggle( checkboxValues[ treeViewItem.path ], treeViewItem.name ); GUILayout.Label( "[" + treeViewItem.status + "]", statusStyle ); //# Button for launching a diff instance. if ( GUILayout.Button( "Diff", GUILayout.Width( 50 ) ) ) { Diff.init( treeViewItem.patchDiff ); } if ( treeViewItem.status.Equals( "Untracked" ) ) { if ( GUILayout.Button( "Ignore", GUILayout.Width( 50 ) ) ) { Debug.Log( console.repo.Info.Path ); console.repo.Ignore.AddPermanentRules( new string[] { treeViewItem.path } ); console.Repaint(); } } EditorGUILayout.EndHorizontal(); } } }