@@ -3,7 +3,6 @@ import path from 'path';
3
3
import React from 'react' ;
4
4
import PropTypes from 'prop-types' ;
5
5
import { TextBuffer } from 'atom' ;
6
- import { CompositeDisposable } from 'event-kit' ;
7
6
8
7
import GitTabView from '../views/git-tab-view' ;
9
8
import UserStore from '../models/user-store' ;
@@ -87,11 +86,6 @@ export default class GitTabController extends React.Component {
87
86
login : this . props . loginModel ,
88
87
config : this . props . config ,
89
88
} ) ;
90
-
91
- this . subs = new CompositeDisposable (
92
- this . usernameBuffer . onDidStopChanging ( this . setUsername ) ,
93
- this . emailBuffer . onDidStopChanging ( this . setEmail ) ,
94
- ) ;
95
89
}
96
90
97
91
static getDerivedStateFromProps ( props , state ) {
@@ -142,6 +136,8 @@ export default class GitTabController extends React.Component {
142
136
143
137
toggleIdentityEditor = { this . toggleIdentityEditor }
144
138
closeIdentityEditor = { this . closeIdentityEditor }
139
+ setLocalIdentity = { this . setLocalIdentity }
140
+ setGlobalIdentity = { this . setGlobalIdentity }
145
141
openInitializeDialog = { this . props . openInitializeDialog }
146
142
openFiles = { this . props . openFiles }
147
143
discardWorkDirChangesForPaths = { this . props . discardWorkDirChangesForPaths }
@@ -371,18 +367,17 @@ export default class GitTabController extends React.Component {
371
367
372
368
closeIdentityEditor = ( ) => this . setState ( { editingIdentity : false } )
373
369
374
- setUsername = ( ) => {
375
- const newUsername = this . usernameBuffer . getText ( ) ;
376
- if ( newUsername !== this . props . username ) {
377
- this . props . repository . setConfig ( 'user.name' , newUsername , { global : true } ) ;
378
- }
379
- }
370
+ setLocalIdentity = ( ) => this . setIdentity ( { } ) ;
380
371
381
- setEmail = ( ) => {
372
+ setGlobalIdentity = ( ) => this . setIdentity ( { global : true } ) ;
373
+
374
+ async setIdentity ( options ) {
375
+ const newUsername = this . usernameBuffer . getText ( ) ;
382
376
const newEmail = this . emailBuffer . getText ( ) ;
383
- if ( newEmail !== this . props . email ) {
384
- this . props . repository . setConfig ( 'user.email' , newEmail , { global : true } ) ;
385
- }
377
+
378
+ await this . props . repository . setConfig ( 'user.name' , newUsername , options ) ;
379
+ await this . props . repository . setConfig ( 'user.email' , newEmail , options ) ;
380
+ this . closeIdentityEditor ( ) ;
386
381
}
387
382
388
383
restoreFocus ( ) {
0 commit comments