/*
File mime type check is not implemented.
$objectResult = $repository->newFileBinary($app->getCachePath(), $repo, $branch, $filename, $name, $email, $comment, $request->get('override') === '1' ? true : false, $_FILES[0]);
{
"filename": "2017-Electronic-Diversity-Visa Lottery-Kriszti.jpg",
"email": "alabard@gmail.com",
"name": "patrikx3",
"comment": "P3X Gitlist Commit New binary",
"upload-file": {
"name": "2017-Electronic-Diversity-Visa Lottery-Kriszti.jpg",
"type": "image\/jpeg",
"tmp_name": "\/tmp\/phpzGVxqY",
"error": 0,
"size": 125931
},
"override": "1"
}
{
"filename": "krip.krip",
"email": "alabard@gmail.com",
"name": "patrikx3",
"comment": "P3X Gitlist Commit New binary",
"upload-file": {
"name": "krip.krip",
"type": "",
"tmp_name": "",
"error": 1,
"size": 0
},
"override": "1"
}
{
"filename": "corifeus-colors.txt",
"email": "alabard@gmail.com",
"name": "patrikx3",
"comment": "P3X Gitlist Commit New binary",
"upload-file": {
"name": "corifeus-colors.txt",
"type": "text\/plain",
"tmp_name": "\/tmp\/phpxjBzT8",
"error": 0,
"size": 133
},
"override": "1"
}
*/
}
public function changeFile($cachePath, $repo, $branch, $repoFilename, $value, $name, $email, $comment) {
return $this->changeRepo($cachePath, $repo, $branch, $repoFilename, $name, $email, $comment, function($client, $filename, $outputs, $tempRepo, $normalizedRepoFilePath) use ($value) {
//$originalFileContent = file_get_contents($filename);
file_put_contents($normalizedRepoFilePath, $value);
return '';
});
}
public function deleteFile($cachePath, $repo, $branch, $repoFilename, $name, $email, $comment) {
return $this->changeRepo($cachePath, $repo, $branch, $repoFilename, $name, $email, $comment, function($client, $filename, $outputs, $tempRepo, $normalizedRepoFilePath) {
//$originalFileContent = file_get_contents($filename);
@unlink($normalizedRepoFilePath);
return 'Deleted ' . $filename;
});
}
public function newFileOrDirectory($cachePath, $repo, $branch, $repoFilename, $name, $email, $comment)
{
return $this->changeRepo($cachePath, $repo, $branch, $repoFilename, $name, $email, $comment, function ($client, $filename, &$outputs, $tempRepo, $normalizedRepoFilePath) use ($repoFilename, $repo, $branch, $name, $email, $comment) {
// array_unshift($outputs, $cachePath);
// array_unshift($outputs, $repoFilename);
/*
array_unshift($outputs, '$tempRepo: ' . $tempRepo);
array_unshift($outputs, '$repo: ' . $repo);
array_unshift($outputs, '$branch: ' . $branch);
array_unshift($outputs, '$repoFilename: ' . $repoFilename);
array_unshift($outputs, '$name: ' . $name);
array_unshift($outputs, '$email: ' . $email);
array_unshift($outputs, '$comment: ' . $comment);
array_unshift($outputs, '$filename: ' . $filename);
array_unshift($outputs, '$repoFilename: ' . $repoFilename);
$basePath = FileSystemPath::fromString($tempRepo);
$repoFilenameItem = FileSystemPath::fromString($repoFilename);
$normalizing = $basePath->resolve($repoFilenameItem);
array_unshift($outputs, '$normalizing: ' . $normalizing);
$normalized = FileSystemPath::fromString($normalizing)->normalize();
array_unshift($outputs, '$normalized: ' . $normalized);
array_unshift($outputs, '$normalizing type: ' . gettype($normalizing));
array_unshift($outputs, '$normalized type: ' . gettype($normalized));
$validPath = strpos($normalizing->__toString(), $normalized->__toString()) !== false;
array_unshift($outputs, 'includes current path in search: ' . ($validPath ? 'true' : 'false'));
return $repoFilename;
*/