-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathversioncontrol_git.admin.inc
More file actions
executable file
·106 lines (99 loc) · 4.16 KB
/
Copy pathversioncontrol_git.admin.inc
File metadata and controls
executable file
·106 lines (99 loc) · 4.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
<?php
// $Id: versioncontrol_git.admin.inc,v 1.6.2.1 2009/04/07 17:35:32 marvil07 Exp $
/**
* @file
* Git backend for Version Control API - Provides Git commit information and
* account management as a pluggable backend.
*
* Copyright 2008 by Jimmy Berry ("boombatower", http://drupal.org/user/214218)
* Copyright 2009 by Cornelius Riemenschneider ("CorniI", http://drupal.org/user/136353)
*/
/**
* Implementation of hook_form_alter(): Add elements to various
* administrative forms that the Version Control API provides.
*/
function versioncontrol_git_form_alter(&$form, $form_state, $form_id) {
if ($form['#id'] == 'versioncontrol-repository-form' && $form['#vcs'] == 'git') {
versioncontrol_git_repository_admin_form_alter($form, $form_state, $form_id);
}
}
/**
* Add Git specific elements to the add/edit repository form.
*/
function versioncontrol_git_repository_admin_form_alter(&$form, $form_state, $form_id) {
$repository = $form['#repository'];
$form['versioncontrol_git'] = array(
'#type' => 'value',
'#value' => TRUE,
);
$form['repository_information']['update_method'] = array(
'#type' => 'radios',
'#title' => t('Update method'),
'#description' => t('Automatic log retrieval requires cron.'),
'#default_value' => !is_null($repository)
? $repository['data']['versioncontrol_git']['update_method']
: VERSIONCONTROL_GIT_UPDATE_CRON,
'#weight' => 9,
'#options' => array(
VERSIONCONTROL_GIT_UPDATE_CRON => t('Automatic log retrieval.'),
VERSIONCONTROL_GIT_UPDATE_XGIT => t('Use external script to insert data.'),
),
);
}
/**
* Implementation of hook_versioncontrol_extract_repository_data():
* Extract Git specific repository additions from the repository
* editing/adding form's submitted values.
*/
function versioncontrol_git_versioncontrol_repository_submit(&$repository, $form, $form_state) {
if (!isset($form['versioncontrol_git'])) {
return array();
}
$update_method = (int)$form_state['values']['update_method'];
$repository['data']['versioncontrol_git']['update_method'] = $update_method;
}
/**
* Implementation of hook_versioncontrol_alter_repository_list():
* Add Git specific columns into the list of Git repositories.
* By changing the @p $header and @p $rows_by_repo_id arguments,
* the repository list can be customized accordingly.
*
* @param $vcs
* The unique string identifier for the version control system that
* the passed repository list covers.
* @param $repositories
* An array of repositories of the given version control system.
* Array keys are the repository ids, and array values are the
* repository arrays like returned from versioncontrol_get_repository().
* @param $header
* A list of columns that will be passed to theme('table').
* @param $rows_by_repo_id
* An array of existing table rows, with repository ids as array keys.
* Each row already includes the generic column values, and for each row
* there is a repository with the same repository id given in the
* @p $repositories parameter.
*/
function versioncontrol_git_versioncontrol_alter_repository_list($vcs, $repositories, &$header, &$rows_by_repo_id) {
if ($vcs != 'git') {
return;
}
$header[] = t('Update method');
$header[] = t('Last updated');
$header[] = t('Locking');
foreach ($rows_by_repo_id as $repo_id => $row) {
if ($repositories[$repo_id]['git_specific']['update_method'] == VERSIONCONTROL_GIT_UPDATE_XGIT) {
$rows_by_repo_id[$repo_id][] = t('external script');
}
if ($repositories[$repo_id]['git_specific']['update_method'] == VERSIONCONTROL_GIT_UPDATE_CRON) {
$rows_by_repo_id[$repo_id][] = t('logs (!fetch)', array(
'!fetch' => l(t('fetch now'), 'admin/project/versioncontrol-repositories/update/git/'. $repo_id)
));
}
$rows_by_repo_id[$repo_id][] = $repositories[$repo_id]['git_specific']['updated']
? format_date($repositories[$repo_id]['git_specific']['updated'], 'small')
: t('never');
$rows_by_repo_id[$repo_id][] = t('Locking (!lock)', array(
'!lock' => l(t('Clear lock now'), 'admin/project/versioncontrol-repositories/clearlock/git/'. $repo_id)
));
}
}