@@ -42,7 +42,8 @@ module.exports = (NodeGit, { constants }, { Config, Feature, Hotfix, Release })
42
42
}
43
43
44
44
return repo . config ( )
45
- . then ( ( config ) => config . getString ( 'gitflow.branch.develop' ) )
45
+ . then ( ( config ) => config . snapshot ( ) )
46
+ . then ( ( snapshot ) => snapshot . getString ( 'gitflow.branch.develop' ) )
46
47
. then ( ( developBranchName ) => NodeGit . Branch . lookup ( repo , developBranchName , NodeGit . Branch . BRANCH . LOCAL ) )
47
48
. then ( ( ) => true )
48
49
. catch ( ( ) => false ) ;
@@ -96,12 +97,19 @@ module.exports = (NodeGit, { constants }, { Config, Feature, Hotfix, Release })
96
97
. then ( ( ) => repo . config ( ) )
97
98
. then ( ( config ) => {
98
99
// Set the config values. We chain them so we don't have concurrent setString calls to the same config file
99
- return configKeys . reduce ( ( last , next ) => {
100
- return last
101
- . then ( ( ) => {
102
- return config . setString ( next , configToUse [ next ] ) ;
103
- } ) ;
104
- } , Promise . resolve ( ) ) ;
100
+ return config . lock ( ) . then ( ( transaction ) => {
101
+ const setPromise = configKeys . reduce ( ( last , next ) => {
102
+ return last
103
+ . then ( ( ) => {
104
+ return config . setString ( next , configToUse [ next ] ) ;
105
+ } ) ;
106
+ } , Promise . resolve ( ) ) ;
107
+
108
+ // NOTE The only way to unlock is to call `commit` or to free the transaction.
109
+ // NodeGit doesn't expose explicitly freeing the transaction, so if setPromise rejects,
110
+ // we simply wait for it to self-free.
111
+ return setPromise . then ( ( ) => transaction . commit ( ) ) ;
112
+ } ) ;
105
113
} )
106
114
. then ( ( ) => createFlowInstance ( repo ) ) ;
107
115
}
@@ -118,9 +126,10 @@ module.exports = (NodeGit, { constants }, { Config, Feature, Hotfix, Release })
118
126
}
119
127
120
128
return repo . config ( )
121
- . then ( ( config ) => {
129
+ . then ( ( config ) => config . snapshot ( ) )
130
+ . then ( ( snapshot ) => {
122
131
const promises = Config . getConfigRequiredKeys ( ) . map ( ( key ) => {
123
- return config . getString ( key ) ;
132
+ return snapshot . getString ( key ) ;
124
133
} ) ;
125
134
126
135
return Promise . all ( promises )
@@ -147,7 +156,8 @@ module.exports = (NodeGit, { constants }, { Config, Feature, Hotfix, Release })
147
156
}
148
157
149
158
return repo . config ( )
150
- . then ( ( config ) => config . getString ( 'gitflow.branch.master' ) )
159
+ . then ( ( config ) => config . snapshot ( ) )
160
+ . then ( ( snapshot ) => snapshot . getString ( 'gitflow.branch.master' ) )
151
161
. then ( ( masterBranchName ) => NodeGit . Branch . lookup ( repo , masterBranchName , NodeGit . Branch . BRANCH . LOCAL ) )
152
162
. then ( ( ) => true )
153
163
. catch ( ( ) => false ) ;
0 commit comments