Commit 00a8b311 authored by Neil Drumm's avatar Neil Drumm 👋
Browse files

Issue #3267669: Remove commitlog overrides, replace with redirects to GitLab

parent f060d63b
Loading
Loading
Loading
Loading
+22 −13
Original line number Diff line number Diff line
@@ -255,7 +255,6 @@ function drupalorg_menu() {
    'file' => 'drupalorg.pages.inc',
  ];
  $items['node/%project/commits'] = [
    'title' => 'Commits',
    'page callback' => 'drupalorg_project_commits_redirect',
    'page arguments' => [1],
    'type' => MENU_CALLBACK,
@@ -264,7 +263,6 @@ function drupalorg_menu() {
    'file' => 'drupalorg.pages.inc',
  ];
  $items['node/%project/commits/feed'] = [
    'title' => 'Commits',
    'page callback' => 'drupalorg_project_commits_redirect',
    'page arguments' => [1, TRUE],
    'type' => MENU_CALLBACK,
@@ -272,6 +270,28 @@ function drupalorg_menu() {
    'access arguments' => ['view', 1],
    'file' => 'drupalorg.pages.inc',
  ];
  $items['user/%user/track/code'] = [
    'page callback' => 'drupalorg_user_commits_redirect',
    'page arguments' => [1],
    'access arguments' => ['access content'],
    'type' => MENU_CALLBACK,
    'file' => 'drupalorg.pages.inc',
  ];
  $items['user/%user/track/code/feed'] = [
    'page callback' => 'drupalorg_user_commits_redirect',
    'page arguments' => [1, TRUE],
    'access arguments' => ['access content'],
    'type' => MENU_CALLBACK,
    'file' => 'drupalorg.pages.inc',
  ];
  $items['commitlog/commit/%versioncontrol_repository/%'] = [
    'page callback' => 'drupalorg_commit_redirect',
    'page arguments' => [2, 3],
    'access arguments' => ['access content'],
    'type' => MENU_CALLBACK,
    'module' => 'drupalorg',
    'file' => 'drupalorg.pages.inc',
  ];
  $items['project/%project/report-security-issue'] = [
    'page callback' => 'drupalorg_project_security_redirect',
    'page arguments' => [1],
@@ -572,17 +592,6 @@ function drupalorg_menu_alter(&$menu) {
  }

  $menu['user']['title callback'] = 'drupalorg_user_menu_title';

  // todo move to drupalorg_menu() once commitlog module is disabled. See
  // https://www.drupal.org/project/drupalorg/issues/3267669
  $menu['commitlog/commit/%versioncontrol_repository/%'] = [
    'page callback' => 'drupalorg_commit_redirect',
    'page arguments' => [2, 3],
    'access arguments' => ['access content'],
    'type' => MENU_CALLBACK,
    'module' => 'drupalorg',
    'file' => 'drupalorg.pages.inc',
  ];
}

/**
+13 −1
Original line number Diff line number Diff line
@@ -22,7 +22,19 @@ function drupalorg_project_commits_redirect(stdClass $node, $feed = FALSE) {
}

/**
 * Page callback for the 'commitlog' family of menu paths.
 * Menu callback, redirect user commits.
 */
function drupalorg_user_commits_redirect(stdClass $account, $feed = FALSE) {
  if ($feed) {
    drupal_goto(variable_get('versioncontrol_gitlab_url') . '/' . $account->git_username . '.atom');
  }
  else {
    drupal_goto(variable_get('versioncontrol_gitlab_url') . '/users/' . $account->git_username . '/activity');
  }
}

/**
 * Redirect an individual commit page.
 *
 * @param VersioncontrolRepository $repository
 * @param string $revision
+0 −57
Original line number Diff line number Diff line
@@ -187,63 +187,6 @@ function drupalorg_versioncontrol_project_promote_sandbox($project) {
  }
}

/**
 * Implements views hook_views_default_views_alter().
 */
function drupalorg_versioncontrol_views_default_views_alter(&$views) {
  // Link #123 pattern on operation messages to issues at drupal.org
  $views_with_tracker_url = array(
    // versioncontrol default views (commitlog)
    'commitlog_repository_commits',
    'commitlog_individual_commit',
    'commitlog_global_commits',
    'commitlog_user_commits',
    // versioncontrol_git default views
    'vc_git_individual_commit',
    // versioncontrol_project default views
    'vc_git_project_commit_view',
    'vc_git_project_global_commits',
    'vc_git_project_user_commits',
    'vc_project_commit_view',
    'vc_project_global_commits',
    'vc_project_user_commits',
  );
  foreach ($views_with_tracker_url as $view_name) {
    if (isset($views[$view_name])) {
      // Link #1234 to issues.
      foreach ($views[$view_name]->display as $display) {
        if (isset($display->display_options['fields']['message'])) {
          if ($display->handler instanceof views_plugin_display_feed) {
            $display->display_options['fields']['message']['issue_tracker_url'] = $GLOBALS['base_url'] . '/node/%issue_id';
          }
          else {
            $display->display_options['fields']['message']['issue_tracker_url'] = '/node/%issue_id';
          }
        }
      }

      // Use views_litepager and remove inner file listings, except on individual commit views.
      if ($view_name != 'commitlog_individual_commit' && $view_name != 'vc_git_individual_commit') {
        if (isset($views[$view_name]->display['default']->display_options)) {
          $views[$view_name]->display['default']->display_options['pager']['type'] = 'lite';
        }
        if (isset($views[$view_name]->display['default']->display_options['fields']['view'])) {
          unset($views[$view_name]->display['default']->display_options['fields']['view']);
        }
      }
      // Disable paging completely on the global commit view because it
      // really doesn't scale.
      if ($view_name == 'vc_git_project_global_commits') {
        $views[$view_name]->display['default']->display_options['pager']['type'] = 'some';
        $views[$view_name]->display['default']->display_options['pager']['options'] = array(
          'items_per_page' => '50',
          'offset' => '0',
        );
      }
    }
  }
}

/**
 * Implements hook_form_alter().
 */