Go to the source code of this file.
|
| saveChangedFileContent (GitRepo $repo) |
|
| generateChangedFilesList ($outputFile, $changedFiles) |
|
| generateBranchesList ($outputFile, $branches, $branchName) |
|
| getChangedFiles (array $changes, array $fileExtensions) |
|
| getRepo ($options, $mainline) |
|
| retrieveChangesAcrossForks ($mainline, GitRepo $repo, $branchName) |
|
| retrieveNewFilesAcrossForks ($mainline, GitRepo $repo, $branchName) |
|
| cleanup ($repo, $mainline) |
|
| validateInput (array $options, array $requiredOptions) |
|
|
const | USAGE <<<USAGE php -f get_github_changes.php -- --output-file="<output_file>" --base-path="<base_path>" --repo="<main_repo>" --branch="<branch>" [--file-extensions="<comma_separated_list_of_formats>"] USAGE |
|
| $options = getopt('', ['output-file:', 'base-path:', 'repo:', 'file-extensions:', 'branch:']) |
|
| $requiredOptions = ['output-file', 'base-path', 'repo', 'branch'] |
|
if(!validateInput($options, $requiredOptions)) | $fileExtensions = explode(',', isset($options['file-extensions']) ? $options['file-extensions'] : 'php') |
|
| $mainline = 'mainline_' . (string)rand(0, 9999) |
|
| $repo = getRepo($options, $mainline) |
|
| $branches = $repo->getBranches('--remotes') |
|
| $changes = retrieveChangesAcrossForks($mainline, $repo, $options['branch']) |
|
| $changedFiles = getChangedFiles($changes, $fileExtensions) |
|
| $additions = retrieveNewFilesAcrossForks($mainline, $repo, $options['branch']) |
|
| $addedFiles = getChangedFiles($additions, $fileExtensions) |
|
| $additionsFile = pathinfo($options['output-file']) |
|
◆ cleanup()
cleanup |
( |
|
$repo, |
|
|
|
$mainline |
|
) |
| |
◆ generateBranchesList()
generateBranchesList |
( |
|
$outputFile, |
|
|
|
$branches, |
|
|
|
$branchName |
|
) |
| |
Generates a file containing origin branches
- Parameters
-
string | $outputFile | |
array | $branches | |
string | $branchName | |
- Returns
- void
Definition at line 98 of file get_github_changes.php.
102 $branchOutputFile = str_replace(
'changed_files',
'branches', $outputFile);
103 $branchesList =
fopen($branchOutputFile,
'w');
104 fwrite($branchesList, $branchName . PHP_EOL);
106 fwrite($branchesList, substr(strrchr($branch,
'/'), 1) . PHP_EOL);
◆ generateChangedFilesList()
generateChangedFilesList |
( |
|
$outputFile, |
|
|
|
$changedFiles |
|
) |
| |
Generates a file containing changed files
- Parameters
-
string | $outputFile | |
array | $changedFiles | |
- Returns
- void
Definition at line 81 of file get_github_changes.php.
85 $changedFilesList =
fopen($outputFile,
'w');
87 fwrite($changedFilesList, $file . PHP_EOL);
◆ getChangedFiles()
getChangedFiles |
( |
array |
$changes, |
|
|
array |
$fileExtensions |
|
) |
| |
Gets list of changed files
- Parameters
-
array | $changes | |
array | $fileExtensions | |
- Returns
- array
Definition at line 116 of file get_github_changes.php.
123 $isFileExension = strpos(
$fileName,
'.' . $extensions);
124 if ($isFileExension) {
if(!validateInput($options, $requiredOptions)) $fileExtensions
foreach($appDirs as $dir) $files
◆ getRepo()
getRepo |
( |
|
$options, |
|
|
|
$mainline |
|
) |
| |
◆ retrieveChangesAcrossForks()
retrieveChangesAcrossForks |
( |
|
$mainline, |
|
|
GitRepo |
$repo, |
|
|
|
$branchName |
|
) |
| |
◆ retrieveNewFilesAcrossForks()
retrieveNewFilesAcrossForks |
( |
|
$mainline, |
|
|
GitRepo |
$repo, |
|
|
|
$branchName |
|
) |
| |
◆ saveChangedFileContent()
saveChangedFileContent |
( |
GitRepo |
$repo | ) |
|
Save changed file content.
- Parameters
-
- Returns
- void
Definition at line 62 of file get_github_changes.php.
67 foreach (
$repo->getChangedContentFiles() as $key => $changedContentFile) {
68 $filePath = sprintf($changedFilesContentFileName, $key);
70 $oldData = json_decode($oldContent,
true);
71 $data = array_merge($oldData, $changedContentFile);
const CHANGED_FILES_CONTENT_FILE
◆ validateInput()
validateInput |
( |
array |
$options, |
|
|
array |
$requiredOptions |
|
) |
| |
Validates input options based on required options
- Parameters
-
array | $options | |
array | $requiredOptions | |
- Returns
- bool
Definition at line 187 of file get_github_changes.php.
192 if (!isset(
$options[$requiredOption]) || empty(
$options[$requiredOption])) {
◆ $addedFiles
◆ $additions
◆ $additionsFile
$additionsFile = pathinfo($options['output-file']) |
◆ $branches
$branches = $repo->getBranches('--remotes') |
◆ $changedFiles
◆ $changes
◆ $fileExtensions
if (!validateInput( $options, $requiredOptions)) $fileExtensions = explode(',', isset($options['file-extensions']) ? $options['file-extensions'] : 'php') |
◆ $mainline
$mainline = 'mainline_' . (string)rand(0, 9999) |
◆ $options
$options = getopt('', ['output-file:', 'base-path:', 'repo:', 'file-extensions:', 'branch:']) |
◆ $repo
$repo = getRepo($options, $mainline) |
◆ $requiredOptions
$requiredOptions = ['output-file', 'base-path', 'repo', 'branch'] |
◆ USAGE
const USAGE <<<USAGE php -f get_github_changes.php -- --output-file="<output_file>" --base-path="<base_path>" --repo="<main_repo>" --branch="<branch>" [--file-extensions="<comma_separated_list_of_formats>"] USAGE |