'value',
'#value' => TRUE,
);
$form['repository_information']['root']['#description'] = t('An absolute path to your bare Git repository, e.g: (/home/user/projects/myrepository.git).');
$form['#validate'][] = 'versioncontrol_git_repository_validate';
}
/**
* Validation of the repository root.
*/
function versioncontrol_git_repository_validate($form, &$form_state) {
// create a non-in-db-repo just for the validation
$repo = new VersioncontrolGitRepository(new VersioncontrolGitBackend());
$repo->root = $form_state['values']['root'];
if (!$repo->isValidGitRepo()) {
form_set_error('root', t('The repository at @root
is not a valid Git bare repository.', array('@root' => $form_state['values']['root'])));
}
}
/**
* Implementation of hook_form_FORM_ID_alter().
*/
function versioncontrol_git_form_versioncontrol_admin_settings_alter(&$form, &$form_state) {
$form['versioncontrol_git'] = array(
'#type' => 'fieldset',
'#title' => t('Git backend configuration'),
'#description' => t('Options to modify how Git backend behaves.'),
'#collapsible' => TRUE,
);
$form['versioncontrol_git']['versioncontrol_git_binary_path'] = array(
'#type' => 'textfield',
'#title' => t('Git binary path'),
'#default_value' => variable_get('versioncontrol_git_binary_path', 'git'),
'#description' => t('Path to the git program to be used. By default it use git
as it assumes the binary is on the $PATH
.'),
'#element_validate' => array('versioncontrol_git_form_versioncontrol_admin_settings_validate_path'),
);
$form['#submit'][] = 'versioncontrol_git_form_versioncontrol_admin_settings_submit';
}
function versioncontrol_git_form_versioncontrol_admin_settings_validate_path($element) {
if ($errors = _versioncontrol_git_binary_check_path($element['#value'])) {
form_set_error($element['#parents'][0], implode('
', $errors));
return FALSE;
}
return TRUE;
}
/**
* Submit function for our alter to versioncontrol_admin_settings form.
*/
function versioncontrol_git_form_versioncontrol_admin_settings_submit(&$form, &$form_state) {
variable_set('versioncontrol_git_binary_path', $form_state['values']['versioncontrol_git_binary_path']);
}