Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Public Member Functions | Data Fields | Protected Member Functions
GitRepo Class Reference

Public Member Functions

 __construct ($workTree)
 
 addRemote ($alias, $url)
 
 removeRemote ($alias)
 
 fetch ($remoteAlias)
 
 getBranches ($source='--all')
 
 compareChanges ($remoteAlias, $remoteBranch, $changesType=self::CHANGE_TYPE_ALL)
 
 getChangedContentFiles ()
 

Data Fields

const CHANGE_TYPE_ADDED = 1
 
const CHANGE_TYPE_MODIFIED = 2
 
const CHANGE_TYPE_ALL = 3
 

Protected Member Functions

 filterChangedFiles (array $changes, $remoteAlias, $remoteBranch, $changesType=self::CHANGE_TYPE_ALL)
 

Detailed Description

Definition at line 198 of file get_github_changes.php.

Constructor & Destructor Documentation

◆ __construct()

__construct (   $workTree)
Parameters
string$workTreeabsolute path to git project

Definition at line 232 of file get_github_changes.php.

235  {
236  if (empty($workTree) || !is_dir($workTree)) {
237  throw new UnexpectedValueException('Working tree should be a valid path to directory');
238  }

Member Function Documentation

◆ addRemote()

addRemote (   $alias,
  $url 
)

Adds remote

Parameters
string$alias
string$url

Definition at line 246 of file get_github_changes.php.

249  {
250  if (isset($this->remoteList[$alias])) {
251  return;
252  }
253  $this->remoteList[$alias] = $url;
254 
if(!trim($html)) $alias
Definition: details.phtml:20

◆ compareChanges()

compareChanges (   $remoteAlias,
  $remoteBranch,
  $changesType = self::CHANGE_TYPE_ALL 
)

Returns files changes between branch and HEAD

Parameters
string$remoteAlias
string$remoteBranch
int$changesType
Returns
array

Definition at line 304 of file get_github_changes.php.

307  {
308  if (!isset($this->remoteList[$remoteAlias])) {
309  throw new LogicException('Alias "' . $remoteAlias . '" is not defined');
310  }
311 
312  $result = $this->call(sprintf('log %s/%s..HEAD --name-status --oneline', $remoteAlias, $remoteBranch));
313 
314  return is_array($result)
315  ? $this->filterChangedFiles(
316  $result,
317  $remoteAlias,
318  $remoteBranch,
319  $changesType
320  )
filterChangedFiles(array $changes, $remoteAlias, $remoteBranch, $changesType=self::CHANGE_TYPE_ALL)

◆ fetch()

fetch (   $remoteAlias)

Fetches remote

Parameters
string$remoteAlias

Definition at line 274 of file get_github_changes.php.

277  {
278  if (!isset($this->remoteList[$remoteAlias])) {
279  throw new LogicException('Alias "' . $remoteAlias . '" is not defined');
280  }
281 

◆ filterChangedFiles()

filterChangedFiles ( array  $changes,
  $remoteAlias,
  $remoteBranch,
  $changesType = self::CHANGE_TYPE_ALL 
)
protected

Makes a diff of file for specified remote/branch and filters only those have real changes

Parameters
array$changes
string$remoteAlias
string$remoteBranch
int$changesType
Returns
array

Definition at line 331 of file get_github_changes.php.

338  {
339  $countScannedFiles = 0;
340  $changedFilesMasks = $this->buildChangedFilesMask($changesType);
341  $filteredChanges = [];
342  foreach ($changes as $fileName) {
343  $countScannedFiles++;
344  if (($countScannedFiles % 5000) == 0) {
345  echo $countScannedFiles . " files scanned so far\n";
346  }
347 
348  $changeTypeMask = $this->detectChangeTypeMask($fileName, $changedFilesMasks);
349  if (null === $changeTypeMask) {
350  continue;
351  }
352 
353  $fileName = trim(substr($fileName, strlen($changeTypeMask)));
354  if (in_array($fileName, $filteredChanges)) {
355  continue;
356  }
357 
358  $fileChanges = $this->getFileChangeDetails($fileName, $remoteAlias, $remoteBranch);
359  if (empty($fileChanges)) {
360  continue;
361  }
362 
363  if (!(isset($this->changedContentFiles[$fileName]))) {
364  $this->setChangedContentFile($fileChanges, $fileName);
365  }
366  $filteredChanges[] = $fileName;
367  }
368  echo $countScannedFiles . " files scanned\n";
369 
$fileName
Definition: translate.phtml:15

◆ getBranches()

getBranches (   $source = '--all')

Returns branches

Parameters
string$source
Returns
array|mixed

Definition at line 289 of file get_github_changes.php.

292  {
293  $result = $this->call(sprintf('branch ' . $source));
294 
$source
Definition: source.php:23

◆ getChangedContentFiles()

getChangedContentFiles ( )

Get changed content files collection.

Returns
array

Definition at line 462 of file get_github_changes.php.

465  {

◆ removeRemote()

removeRemote (   $alias)

Remove remote

Parameters
string$alias

Definition at line 261 of file get_github_changes.php.

264  {
265  if (isset($this->remoteList[$alias])) {
266  $this->call(sprintf('remote rm %s', $alias));
267  unset($this->remoteList[$alias]);
if(!trim($html)) $alias
Definition: details.phtml:20

Field Documentation

◆ CHANGE_TYPE_ADDED

const CHANGE_TYPE_ADDED = 1

Definition at line 201 of file get_github_changes.php.

◆ CHANGE_TYPE_ALL

const CHANGE_TYPE_ALL = 3

Definition at line 203 of file get_github_changes.php.

◆ CHANGE_TYPE_MODIFIED

const CHANGE_TYPE_MODIFIED = 2

Definition at line 202 of file get_github_changes.php.


The documentation for this class was generated from the following file: