浏览代码

Added fetching branch before checkout in git.checkout method in dev tools.

Szymon Kupś 9 年之前
父节点
当前提交
510b28a670
共有 2 个文件被更改,包括 7 次插入2 次删除
  1. 2 1
      dev/tasks/dev/utils/git.js
  2. 5 1
      dev/tests/dev/git.js

+ 2 - 1
dev/tasks/dev/utils/git.js

@@ -66,7 +66,7 @@ module.exports = {
 	},
 
 	/**
-	 * Checks out branch on selected repository.
+	 * Fetches and checks out branch on selected repository.
 	 *
 	 * @param {String} repositoryLocation Absolute path to repository.
 	 * @param {String} branchName Name of the branch to checkout.
@@ -74,6 +74,7 @@ module.exports = {
 	checkout( repositoryLocation, branchName ) {
 		const checkoutCommands = [
 			`cd ${ repositoryLocation }`,
+			`git fetch origin ${ branchName }`,
 			`git checkout ${ branchName }`
 		];
 

+ 5 - 1
dev/tests/dev/git.js

@@ -149,7 +149,11 @@ describe( 'utils', () => {
 				const shExecStub = sandbox.stub( tools, 'shExec' );
 				const repositoryLocation = 'path/to/repository';
 				const branchName = 'branch-to-checkout';
-				const checkoutCommands = `cd ${ repositoryLocation } && git checkout ${ branchName }`;
+				const checkoutCommands = [
+					`cd ${ repositoryLocation }`,
+					`git fetch origin ${ branchName }`,
+					`git checkout ${ branchName }`
+				].join( ' && ' );
 
 				git.checkout( repositoryLocation, branchName );