'Git Repository Manager Configuration', 'description' => 'Manage settings related to how Git repositories are managed on disk.', 'page callback' => 'drupal_get_form', 'page arguments' => array('versioncontrol_git_repo_manager_settings_form'), 'access arguments' => array('administer site configuration'), 'file' => 'versioncontrol_git_repo_manager.admin.inc', 'type' => MENU_NORMAL_ITEM, ); return $items; } /** * Implements hook_cron_queue_info(). * * Inform the job queueing system about our worker callback. */ function versioncontrol_git_repo_manager_cron_queue_info() { $queues = array(); $queues['versioncontrol_git_repo_parsing'] = array( 'worker callback' => 'versioncontrol_git_repo_parsing_worker_callback', 'time' => 0, ); return $queues; } /** * Worker callback for the versioncontrol_git_repo_activity_stream queue. * * @param array $data */ function versioncontrol_git_repo_activity_stream_worker_callback($data) { } /** * Worker callback for the versioncontrol_git_repo_parsing queue. * * @param array $data */ function versioncontrol_git_repo_parsing_worker_callback($data) { if (empty($data['repo_id'])) { throw new Exception('No repository id passed in for parsing job.'); } // Invoke notification hook indicating that we've received the ref updates, but not parsed them yet. module_invoke_all('versioncontrol_git_raw_push_data', $data); // Highly unsafe to cache the repo in memory, since it will miss updates // resulting from, say, project promotions. $repository = versioncontrol_repository_load($data['repo_id'], array(), array('may cache' => FALSE)); if (!$repository instanceof VersioncontrolGitRepository) { throw new Exception("No repository could be found with id {$data['repo_id']}."); } // Perform a full sync. This is pretty wasteful and needs improving. $repository->fetchLogs(); $all_refdata = explode("\n", $data['data']); $refs = array(); $refs['branches'] = $refs['tags'] = array(); foreach ($all_refdata as $refdata) { if (empty($refdata)) { continue; // last element is usually empty, skip it } list($start, $end, $refpath) = explode(' ', $refdata); list(, $type, $ref) = explode('/', $refpath); $refs[$type == 'heads' ? 'branches' : 'tags'][$ref] = $ref; } if (!empty($refs['branches'])) { $branches = $repository->loadBranches(array(), array('name' => array_values($refs['branches']))); foreach ($branches as $branch) { $refs['branches'][$branch->name] = $branch; } } if (!empty($refs['tags'])) { $tags = $repository->loadTags(array(), array('name' => array_values($refs['tags']))); foreach ($tags as $tag) { $refs['tags'][$tag->name] = $tag; } } // Invoke notification hook that new repo data has been updated in the db. module_invoke_all('versioncontrol_git_refs_updated', $repository, $refs); }