public function update($dryRun = true, $allowNonFf = false, $source = null)
	{
		if (!$dryRun)
		{
			// Move to the working tree dir (git 1.8.5 has a built in option for this...but we're still generally running 1.7.x)
			chdir($this->workTree);

			$arguments = array();

			if (isset($source))
			{
				$arguments[] = $source;
			}
			else
			{
				$arguments[] = $this->upstream;
			}

			// Add fast forward only arg if applicable
			if (!$allowNonFf)
			{
				$arguments[] = '--ff-only';
			}

			// Doing some trickery here.
			// Newer versions of git prefer you to edit the auto generated message after every merge...we don't want to do this
			// There is an option to prevent that (--no-edit), but it doesn't apply to older versions of git
			// Thus we're going to use an env variable to prevent the behavior on newer versions, while not effecting older
			// versions that are currently unaware of the --no-edit option

			// Start off by seeing if there is an autoedit env var already set
			$autoedit = getenv("GIT_MERGE_AUTOEDIT");
			// Now set it to no
			putenv("GIT_MERGE_AUTOEDIT=no");

			// Now do the actual pull
			$response = $this->call('merge', $arguments);

			// Now clear the var or reset it if it had been previously set
			if ($autoedit)
			{
				putenv("GIT_MERGE_AUTOEDIT={$autoedit}");
			}
			else
			{
				putenv("GIT_MERGE_AUTOEDIT");
			}

			$response  = trim($response);
			$return    = array();

			if (substr($response, 0, 5) == 'fatal')
			{
				$return['status']  = 'fatal';
				$return['message'] = trim(substr($response, stripos($response, 'fatal') + 6));
			}
			else if (substr($response, 0, 5) == 'error')
			{
				$return['status']  = 'fatal';
				$return['message'] = trim(substr($response, stripos($response, 'error') + 6));
			}
			else if (stripos($response, 'automatic merge failed') !== false)
			{
				$return['status']  = 'fatal';
				$return['message'] = $response;
			}
			else
			{
				$return['status'] = 'success';
			}

			// Include the raw return for all calls
			$return['raw'] = $response;
		}
		else
		{
			// Be sure to fetch so we known we're up-to-date
			$this->call('fetch');
			$this->call('remote update');

			// Build arguments
			$arguments = array(
				'--pretty=format:"%an: \"%s\" (%ar)"',
				"HEAD..{$this->upstream}"
			);

			// Make call to get log differences between us and origin
			$log    = $this->call('log', $arguments);
			$log    = trim($log);
			$return = array();
			$logs   = explode("\n", $log);

			if (!empty($log) && count($logs) > 0)
			{
				foreach ($logs as $log)
				{
					$return[] = trim($log);
				}
			}
		}

		return $return;
	}
public function update($dryRun = true, $allowNonFf = false, $source = null)
	{
		if (!$dryRun)
		{
			// Move to the working tree dir (git 1.8.5 has a built in option for this...but we're still generally running 1.7.x)
			chdir($this->workTree);

			$arguments = array();

			if (isset($source))
			{
				$arguments[] = $source;
			}
			else
			{
				$arguments[] = $this->upstream;
			}

			// Add fast forward only arg if applicable
			if (!$allowNonFf)
			{
				$arguments[] = '--ff-only';
			}

			// Doing some trickery here.
			// Newer versions of git prefer you to edit the auto generated message after every merge...we don't want to do this
			// There is an option to prevent that (--no-edit), but it doesn't apply to older versions of git
			// Thus we're going to use an env variable to prevent the behavior on newer versions, while not effecting older
			// versions that are currently unaware of the --no-edit option

			// Start off by seeing if there is an autoedit env var already set
			$autoedit = getenv("GIT_MERGE_AUTOEDIT");
			// Now set it to no
			putenv("GIT_MERGE_AUTOEDIT=no");

			// Now do the actual pull
			$response = $this->call('merge', $arguments);

			// Now clear the var or reset it if it had been previously set
			if ($autoedit)
			{
				putenv("GIT_MERGE_AUTOEDIT={$autoedit}");
			}
			else
			{
				putenv("GIT_MERGE_AUTOEDIT");
			}

			$response  = trim($response);
			$return    = array();

			if (substr($response, 0, 5) == 'fatal')
			{
				$return['status']  = 'fatal';
				$return['message'] = trim(substr($response, stripos($response, 'fatal') + 6));
			}
			else if (substr($response, 0, 5) == 'error')
			{
				$return['status']  = 'fatal';
				$return['message'] = trim(substr($response, stripos($response, 'error') + 6));
			}
			else if (stripos($response, 'automatic merge failed') !== false)
			{
				$return['status']  = 'fatal';
				$return['message'] = $response;
			}
			else
			{
				$return['status'] = 'success';
			}

			// Include the raw return for all calls
			$return['raw'] = $response;
		}
		else
		{
			// Be sure to fetch so we known we're up-to-date
			$this->call('fetch');
			$this->call('remote update');

			// Build arguments
			$arguments = array(
				'--pretty=format:"%an: \"%s\" (%ar)"',
				"HEAD..{$this->upstream}"
			);

			// Make call to get log differences between us and origin
			$log    = $this->call('log', $arguments);
			$log    = trim($log);
			$return = array();
			$logs   = explode("\n", $log);

			if (!empty($log) && count($logs) > 0)
			{
				foreach ($logs as $log)
				{
					$return[] = trim($log);
				}
			}
		}

		return $return;
	}
public function update ( $ dryRun = true , $ allowNonFf = false , $ source = null ) { if ( ! $ dryRun ) { // Move to the working tree dir (git 1.8.5 has a built in option for this...but we're still generally running 1.7.x) chdir ( $ this -> workTree ) ; $ arguments = array ( ) ; if ( isset ( $ source ) ) { $ arguments [ ] = $ source ; } else { $ arguments [ ] = $ this -> upstream ; } // Add fast forward only arg if applicable if ( ! $ allowNonFf ) { $ arguments [ ] = '--ff-only' ; } // Doing some trickery here. // Newer versions of git prefer you to edit the auto generated message after every merge...we don't want to do this // There is an option to prevent that (--no-edit), but it doesn't apply to older versions of git // Thus we're going to use an env variable to prevent the behavior on newer versions, while not effecting older // versions that are currently unaware of the --no-edit option // Start off by seeing if there is an autoedit env var already set $ autoedit = getenv ( "GIT_MERGE_AUTOEDIT" ) ; // Now set it to no putenv ( "GIT_MERGE_AUTOEDIT=no" ) ; // Now do the actual pull $ response = $ this -> call ( 'merge' , $ arguments ) ; // Now clear the var or reset it if it had been previously set if ( $ autoedit ) { putenv ( "GIT_MERGE_AUTOEDIT={$autoedit}" ) ; } else { putenv ( "GIT_MERGE_AUTOEDIT" ) ; } $ response = trim ( $ response ) ; $ return = array ( ) ; if ( substr ( $ response , 0 , 5 ) == 'fatal' ) { $ return [ 'status' ] = 'fatal' ; $ return [ 'message' ] = trim ( substr ( $ response , stripos ( $ response , 'fatal' ) + 6 ) ) ; } else if ( substr ( $ response , 0 , 5 ) == 'error' ) { $ return [ 'status' ] = 'fatal' ; $ return [ 'message' ] = trim ( substr ( $ response , stripos ( $ response , 'error' ) + 6 ) ) ; } else if ( stripos ( $ response , 'automatic merge failed' ) !== false ) { $ return [ 'status' ] = 'fatal' ; $ return [ 'message' ] = $ response ; } else { $ return [ 'status' ] = 'success' ; } // Include the raw return for all calls $ return [ 'raw' ] = $ response ; } else { // Be sure to fetch so we known we're up-to-date $ this -> call ( 'fetch' ) ; $ this -> call ( 'remote update' ) ; // Build arguments $ arguments = array ( '--pretty=format:"%an: \"%s\" (%ar)"' , "HEAD..{$this->upstream}" ) ; // Make call to get log differences between us and origin $ log = $ this -> call ( 'log' , $ arguments ) ; $ log = trim ( $ log ) ; $ return = array ( ) ; $ logs = explode ( "\n" , $ log ) ; if ( ! empty ( $ log ) && count ( $ logs ) > 0 ) { foreach ( $ logs as $ log ) { $ return [ ] = trim ( $ log ) ; } } } return $ return ; }
Pull the latest updates

@param   bool    $dryRun      Whether or not to do the run, or just check what's incoming
@param   bool    $allowNonFf  Whether or not to allow non fast forward pulls (i.e. merges)
@param   string  $source      Where this repository should pull from (this should be a valid git remote/branch)
@return  string
Pull the latest updates