mirror of
https://github.com/standardebooks/web.git
synced 2025-07-05 06:10:36 -04:00
Update GitHub webhook to work for ebooks whose repo names are so long that they have to be truncated in GitHub.
This commit is contained in:
parent
0a565c3e00
commit
e44a6bffa2
1 changed files with 11 additions and 2 deletions
|
@ -5,6 +5,7 @@ use function Safe\substr;
|
|||
use function Safe\file_get_contents;
|
||||
use function Safe\preg_replace;
|
||||
use function Safe\json_decode;
|
||||
use function Safe\glob;
|
||||
|
||||
// Get a semi-random ID to identify this request within the log.
|
||||
$requestId = substr(sha1(time() . rand()), 0, 8);
|
||||
|
@ -61,8 +62,16 @@ try{
|
|||
$dir = REPOS_PATH . '/' . $repoName . '.git/';
|
||||
|
||||
// Confirm we're looking at a Git repo in our filesystem
|
||||
if(!file_exists($dir . "HEAD")){
|
||||
throw new WebhookException('Couldn\'t find repo "' . $repoName . '" in filesystem at "' . $dir . '".', $post);
|
||||
if(!file_exists($dir . 'HEAD')){
|
||||
// We might be looking for a repo whose name is so long, it was truncated for GitHub. Try to check that here by simply globbing the rest.
|
||||
$dirs = glob(REPOS_PATH . '/' . $repoName . '*');
|
||||
if(sizeof($dirs) == 1){
|
||||
$dir = rtrim($dirs[0], '/') . '/';
|
||||
}
|
||||
|
||||
if(!file_exists($dir . 'HEAD')){
|
||||
throw new WebhookException('Couldn\'t find repo "' . $repoName . '" in filesystem at "' . $dir . '".', $post);
|
||||
}
|
||||
}
|
||||
|
||||
Logger::WriteGithubWebhookLogEntry($requestId, 'Processing ebook "' . $repoName . '" located at "' . $dir . '".');
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue