The Git Backend can be used to retrieve and view commit information. The commit information can either be retreived automatically through the use of the xgit scripts or using the fetch now link on the project administration repository page. The logs are then defaultly avaliable through the commitlog page.

Information reguarding the setup of xgit scripts is aviable in the README.txt located in the xgit directory.

If you have any questions, comments, or feature requests please visit the module page and post your concerns in the issue quene.

'; } return $output; } /** * Implementation of hook_versioncontrol_backends(). */ function versioncontrol_git_versioncontrol_backends() { return array( // The array key is up to 8 characters long, and used as unique identifier // for this VCS, in functions, URLs and in the database. 'git' => array( // The user-visible name of the VCS. 'name' => 'Git', // A short description of the VCS, if possible not longer than one or two sentences. 'description' => t('Git is a fast, scalable, distributed revision control system with an unusually rich command set that provides both high-level operations and full access to internals.'), // A list of optional capabilities, in addition to the required retrieval // of detailed commit information. 'capabilities' => array( // Use the commit hash for to identify the commit instead of an idvidual // revision for each file. VERSIONCONTROL_CAPABILITY_ATOMIC_COMMITS ), // An array listing which tables should be managed by Version Control API // instead of doing it manually in the backend. 'flags' => array( // versioncontrol_insert_repository() will automatically insert // array elements from $repository['git_specific'] into // {versioncontrol_git_repositories} and versioncontrol_get_repositories() // will automatically fetch it from there. VERSIONCONTROL_FLAG_AUTOADD_REPOSITORIES, ), ), ); } /** * Implementation of hook_menu(). */ function versioncontrol_git_menu() { $items = array(); $items['admin/project/versioncontrol-repositories/clearlock/git'] = array( 'title' => 'Clear lock', 'page callback' => 'versioncontrol_git_clearlock_repository_callback', 'access arguments' => array('administer version control systems'), 'type' => MENU_CALLBACK, ); $items['admin/project/versioncontrol-repositories/update/git'] = array( 'title' => 'Fetch log', 'page callback' => 'versioncontrol_git_update_repository_callback', 'access arguments' => array('administer version control systems'), 'type' => MENU_CALLBACK, ); return $items; } /** * Implementation of hook_cron() */ function versioncontrol_git_cron() { // get repositories that have log fetching enabled $result = db_query("SELECT repo_id FROM {versioncontrol_git_repositories} WHERE update_method = %d", VERSIONCONTROL_GIT_UPDATE_CRON); // Set timeout limit to 3600 seconds as it can take a long time to process // the log initially. (And hook_cron() might be called by poormanscron.) if (!ini_get('safe_mode')) { set_time_limit(3600); } while ($repo = db_fetch_object($result)) { $repository = versioncontrol_get_repository($repo->repo_id); if (isset($repository)) { _versioncontrol_git_update_repository($repository); } } } /** * Implementation of hook_get_selected_label_from_operation(). */ function versioncontrol_git_get_selected_label_from_operation($operation, $target_item) { // TODO: implement tag support here, tags>branch? // better not, after looking it again current code is OK. // just take the first branch, dunno what else we should do here... // jpetso knows neither :P return $operation['labels'][0]; } function _versioncontrol_git_get_branch_intersect($repository, $item1, $item2) { $constraints = array( 'revisions' => array($item1['revision'], $item2['revision']), 'vcs' => array('git'), 'repo_ids' => array($repository['repo_id']), 'types' => array(VERSIONCONTROL_OPERATION_COMMIT) ); $commit_ops = versioncontrol_get_operations($constraints); $branches1 = array(); $branches2 = array(); foreach ($commit_ops as $vc_op_id => $op) { foreach ($op['labels'] as $label) { if ($label['type'] === VERSIONCONTROL_OPERATION_BRANCH) { if ($op['revision'] == $item1['revision']) { $branches1[]=$label; } else if ($op['revision'] == $item2['revision']) { $branches2[]=$label; } } } } $branches = array_intersect($branches1, $branches2); return array_pop($branches); // We don't know any keys in $branches, so we use array_pop here. Also it'll return NULL if needed } /** * Implementation of hook_get_selected_label_from_other_item(). */ function versioncontrol_git_get_selected_label_from_other_item($repository, $target_item, &$other_item, $other_item_tags = array()) { // First up, optimizations - maybe we can do without the generic // "label transfer" code from further down and use assumptions instead. // Let's assume for FakeVCS repositories that if an item wears a label, then // an item at another path but with the same (file-level) revision can also // wear that same label. That is the case with some version control systems // (e.g. Git, Mercurial, Bazaar) but might not be the case with others // (CVS for its lack of global revision identifiers, SVN for its use of // directory structure as tag/branch identifiers). if ($target_item['revision'] == $other_item['revision']) { return versioncontrol_get_item_selected_label($repository, $other_item); } //can be maybe optimized for speed by using the hints provided return _versioncontrol_git_get_branch_intersect($repository, $target_item, $other_item); } /** * Implementation of hook_account_username_suggestion(). */ function versioncontrol_git_account_username_suggestion($repository, $user) { // @TODO: adjust later // Use the kindof standard git identifier here, it's nothing too serious. return $user->name ." <$user->mail>"; } /** * Implementation of hook_is_account_username_valid(). */ function versioncontrol_git_is_account_username_valid($repository, &$username) { // @TODO: adjust, too // We want to allow "prename name " // Or just "nick " // Or just whatever naming convention you like // This means, we just check for control characters and NULs here if (preg_match("/[\\x00-\\x1f]/", $username) == 0) { return TRUE; } return FALSE; } /** * Menu callback for 'admin/project/versioncontrol-repositories/clearlock/git' * (expecting a $repo_id as one more path argument): * Clears the update lock for the specified repository */ function versioncontrol_git_clearlock_repository_callback($repo_id) { if (is_numeric($repo_id)) { db_query('UPDATE {versioncontrol_git_repositories} SET locked = 0 WHERE repo_id = %d', $repo_id); drupal_set_message(t('Cleared the lock for the repository.')); } drupal_goto('admin/project/versioncontrol-repositories'); } /** * Menu callback for 'admin/project/versioncontrol-repositories/update/git' * (expecting a $repo_id as one more path argument): * Retrieve/validate the specified repository, fetch new commits, tags * and branches by invoking the git executable, output messages and * redirect back to the repository page. */ function versioncontrol_git_update_repository_callback($repo_id) { if (is_numeric($repo_id)) { $repository = versioncontrol_get_repository($repo_id); if (isset($repository)) { $update_method = $repository['git_specific']['update_method']; } } if (isset($update_method) && $update_method == VERSIONCONTROL_GIT_UPDATE_CRON) { // Set timeout limit to 3600 seconds as it can take a long time // to process the log initially. if (!ini_get('safe_mode')) { set_time_limit(3600); } if (_versioncontrol_git_update_repository($repository)) { drupal_set_message(t('Fetched new log entries.')); } else { drupal_set_message(t('Error while fetching new log entries.'), 'error'); } } else { // $repo_id is not a number or doesn't correlate to any repository. drupal_set_message(t('No such repository, did not fetch anything.')); } drupal_goto('admin/project/versioncontrol-repositories'); } /** * Actually update the repository by fetching commits and other stuff * directly from the repository, invoking the git executable. * * @return * TRUE if the logs were updated, or FALSE if fetching and updating the logs * failed for whatever reason. */ function _versioncontrol_git_update_repository(&$repository) { include_once(drupal_get_path('module', 'versioncontrol_git') .'/versioncontrol_git.log.inc'); return _versioncontrol_git_log_update_repository($repository); } /** * Implementation of hook_format_revision_identifier(). */ function versioncontrol_git_format_revision_identifier($repository, $revision, $format = 'full') { switch ($format) { case 'short': // Let's return only the first 7 characters of the revision identifier, // like git log --abbrev-commit does by default. return substr($revision, 0, 7); case 'full': default: return $revision; } }