Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions Source/MantisSourceGitBasePlugin.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ abstract class MantisSourceGitBasePlugin extends MantisSourcePlugin
*
*/
const CFG_DEFAULT_PRIMARY_BRANCH = 'git_default_primary_branch';
const CFG_DEFAULT_URL = 'git_default_url';

/**
* Error constants
Expand Down Expand Up @@ -143,6 +144,22 @@ public function update_config_form() {
<span class="small"><?php echo plugin_lang_get( 'git_default_primary_branch_info' ) ?></span>
</td>
</tr>
<tr>
<td class="category">
<label for="<?php echo self::CFG_DEFAULT_URL ?>">
<?php echo plugin_lang_get( self::CFG_DEFAULT_URL ) ?>
</label>
</td>
<td>
<input id="<?php echo self::CFG_DEFAULT_URL ?>"
name="<?php echo self::CFG_DEFAULT_URL ?>"
type="text" class="input-sm" size="50"
value="<?php echo string_attribute( plugin_config_get( self::CFG_DEFAULT_URL, '' ) ) ?>"
/>
<br>
<span class="small"><?php echo plugin_lang_get( self::CFG_DEFAULT_URL . '_info' ) ?></span>
</td>
</tr>
<tr></tr>
<?php
plugin_pop_current();
Expand All @@ -163,6 +180,12 @@ public function update_config() {
if ( $f_default_branch != $t_default_branch ) {
plugin_config_set( self::CFG_DEFAULT_PRIMARY_BRANCH, $f_default_branch );
}

$f_default_url = rtrim( trim( gpc_get_string( self::CFG_DEFAULT_URL, '' ) ), '/' );
$t_default_url = plugin_config_get( self::CFG_DEFAULT_URL, '' );
if( $f_default_url !== $t_default_url ) {
plugin_config_set( self::CFG_DEFAULT_URL, $f_default_url );
}
plugin_pop_current();
}
}
Expand Down
6 changes: 6 additions & 0 deletions Source/MantisSourcePlugin.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,12 @@ abstract public function url_file( $p_repo, $p_changeset, $p_file );
*/
abstract public function url_diff( $p_repo, $p_changeset, $p_file );

/**
* Output additional action buttons on the Manage Repository page.
* @param SourceRepo $p_repo Repository
*/
public function show_manage_actions( $p_repo ) {}

/**
* Output form elements for custom repository data.
* @param SourceRepo $p_repo Repository
Expand Down
2 changes: 2 additions & 0 deletions Source/lang/strings_english.txt
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,8 @@ $s_plugin_Source_enable_product_matrix = 'Product Matrix Integration';
$s_plugin_Source_git_title = 'Git-based Plugins Integration';
$s_plugin_Source_git_default_primary_branch = 'Default primary branches';
$s_plugin_Source_git_default_primary_branch_info = 'Default Branches to use when creating a repository (comma-separated list or *).';
$s_plugin_Source_git_default_url = 'Default instance URL';
$s_plugin_Source_git_default_url_info = 'Default root URL to pre-fill when creating a new repository (e.g. https://bitbucket.example.com). Trailing slash is stripped automatically.';

$s_plugin_Source_branch_mapping = 'Branch Mappings';
$s_plugin_Source_mapping_update = 'Update Mappings';
Expand Down
9 changes: 8 additions & 1 deletion Source/pages/checkin.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,17 @@


$t_api_key = plugin_config_get( 'api_key' );
if ( gpc_get_string( 'api_key' ) == $t_api_key && trim( $t_api_key ) != '') {
if ( gpc_get_string( 'api_key', '' ) == $t_api_key && trim( $t_api_key ) != '') {
$t_valid = true;
}

# Allow requests carrying an X-Hub-Signature header to pass the gate.
# Per-repo HMAC verification is performed inside EVENT_SOURCE_PRECOMMIT;
# if validation fails there the request is rejected before any data is written.
if( !$t_valid && isset( $_SERVER['HTTP_X_HUB_SIGNATURE'] ) ) {
$t_valid = !empty( file_get_contents( 'php://input' ) );
}

# Not validated by this point gets the boot!
if ( !$t_valid ) {
http_response_code( HTTP_STATUS_BAD_REQUEST );
Expand Down
2 changes: 1 addition & 1 deletion Source/pages/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@
. form_security_param( 'plugin_Source_repo_delete' ) ?>">
<?php echo plugin_lang_get( 'delete' ) ?>
</a>
<?php } ?>
<?php } ?>
<a class="btn btn-xs btn-primary btn-white btn-round" href="<?php echo plugin_page( 'repo_manage_page' ) . '&id=' . $t_repo->id ?>">
<?php echo plugin_lang_get( 'manage' ) ?>
</a>
Expand Down
5 changes: 2 additions & 3 deletions Source/pages/repo_manage_page.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ function convert_to_key_value( $p_array ) {
<a class="btn btn-xs btn-primary btn-white btn-round" href="<?php echo plugin_page( 'index' ) ?>">
<?php echo plugin_lang_get( 'back' ) ?>
</a>
<?php $t_vcs->show_manage_actions( $t_repo ) ?>
</div>
<div class="table-responsive">

Expand Down Expand Up @@ -221,17 +222,15 @@ function convert_to_key_value( $p_array ) {
$t_mappings[] = new SourceMapping( null, null, null );

foreach( $t_mappings as $t_mapping ) {
$t_branch = str_replace( '.', '_', $t_mapping->branch );
# Since it is not possible to update the branch's name (see #230),
# the input field is disabled, except for the 'new mapping' row
$t_disabled = 'disabled';
if( is_null( $t_mapping->branch ) ) {
$t_branch = '';
$t_disabled = '';
if( count( $t_mappings ) > 1 ) {
echo '<tr class="spacer"></tr>';
}
} else {
$t_branch = str_replace( '.', '_', $t_mapping->branch );
}
?>
<tr>
Expand Down
Loading