@@ -111,48 +111,30 @@ module.exports = function (grunt) {
111111 // task: git
112112 grunt . registerMultiTask ( "git" , "Pull specified repo branch from origin" , function ( ) {
113113 var repo = this . data . repo ;
114-
114+
115115 if ( ! repo ) {
116116 grunt . fail . fatal ( "Missing repo config" ) ;
117117 }
118-
118+
119119 repo = resolve ( repo ) ;
120-
120+
121121 if ( this . data . branch ) {
122122 grunt . log . writeln ( "Updating repo " + this . target + " at " + repo + " to branch " + this . data . branch ) ;
123123
124124 var done = this . async ( ) ,
125- branchExists = spawn ( [
125+ promise = spawn ( [
126126 "git fetch origin" ,
127- "git checkout " + this . data . branch
128- ] ) ,
129- commands ;
130-
131- branchExists . then ( function ( succesResult ) {
132- var branch = succesResult . args [ 1 ] ;
133- commands = [
134- "git pull origin " + branch ,
127+ "git checkout " + this . data . branch ,
128+ "git pull origin " + this . data . branch ,
135129 "git submodule sync" ,
136130 "git submodule update --init --recursive"
137- ] ;
138- } , function ( rejectedResult ) {
139- var branch = rejectedResult . args [ 1 ] ;
140- commands = [
141- "git checkout -t -b " + branch + " origin/" + branch ,
142- "git submodule sync" ,
143- "git submodule update --init --recursive"
144- ] ;
145- } ) ;
146-
147- branchExists . finally ( function ( ) {
148- var promise = spawn ( commands , { cwd : repo } ) ;
149-
150- promise . then ( function ( ) {
151- done ( ) ;
152- } , function ( err ) {
153- grunt . log . writeln ( err ) ;
154- done ( false ) ;
155- } ) ;
131+ ] , { cwd : repo } ) ;
132+
133+ promise . then ( function ( ) {
134+ done ( ) ;
135+ } , function ( err ) {
136+ grunt . log . writeln ( err ) ;
137+ done ( false ) ;
156138 } ) ;
157139 } else {
158140 grunt . log . writeln ( "Skipping fetch for " + this . target + " repo" ) ;
0 commit comments