Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
New plugin to allow linking of changeset information to an SVN repository fronted by ViewVC - http://www.viewvc.org/ PR #141
- Loading branch information
Showing
5 changed files
with
287 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
Copyright (c) 2015 John Bailey | ||
|
||
Permission is hereby granted, free of charge, to any person | ||
obtaining a copy of this software and associated documentation | ||
files (the "Software"), to deal in the Software without | ||
restriction, including without limitation the rights to use, | ||
copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the | ||
Software is furnished to do so, subject to the following | ||
conditions: | ||
|
||
The above copyright notice and this permission notice shall be | ||
included in all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES | ||
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT | ||
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, | ||
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | ||
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR | ||
OTHER DEALINGS IN THE SOFTWARE. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,169 @@ | ||
<?php | ||
|
||
# Copyright (c) 2015 John Bailey | ||
# Copyright (c) 2012 John Reese | ||
# Licensed under the MIT license | ||
|
||
if ( false === include_once( config_get( 'plugin_path' ) . 'SourceSVN/SourceSVN.php' ) ) { | ||
return; | ||
} | ||
|
||
class SourceViewVCPlugin extends SourceSVNPlugin { | ||
public function register() { | ||
$this->name = lang_get( 'plugin_SourceViewVC_title' ); | ||
$this->description = lang_get( 'plugin_SourceViewVC_description' ); | ||
|
||
$this->version = '0.1'; | ||
$this->requires = array( | ||
'MantisCore' => '1.2.0', | ||
'Source' => '0.16', | ||
'SourceSVN' => '0.16', | ||
); | ||
|
||
$this->author = 'John Bailey'; | ||
$this->contact = 'dev@brightsilence.com'; | ||
$this->url = 'https://github.com/mantisbt-plugins/source-integration'; | ||
} | ||
|
||
public $type = 'viewvc'; | ||
|
||
public function show_type() { | ||
return lang_get( 'plugin_SourceViewVC_svn' ); | ||
} | ||
|
||
public function get_viewvc_url( $p_repo ) { | ||
return isset( $p_repo->info['viewvc_url'] ) | ||
? $p_repo->info['viewvc_url'] | ||
: ''; | ||
} | ||
|
||
public function get_viewvc_name( $p_repo ) { | ||
return isset( $p_repo->info['viewvc_name'] ) | ||
? $p_repo->info['viewvc_name'] | ||
: ''; | ||
} | ||
|
||
public function get_viewvc_use_checkout( $p_repo ) { | ||
return isset( $p_repo->info['viewvc_use_checkout'] ) | ||
? $p_repo->info['viewvc_use_checkout'] | ||
: false; | ||
} | ||
|
||
public function get_viewvc_root_as_url( $p_repo ) { | ||
return isset( $p_repo->info['viewvc_root_as_url'] ) | ||
? $p_repo->info['viewvc_root_as_url'] | ||
: false; | ||
} | ||
|
||
/** | ||
* Builds the ViewVC URL base string | ||
* @param object $p_repo repository | ||
* @param string $p_file optional filename (as absolute path from root) | ||
* @param array $p_opts optional additional ViewVC URL parameters | ||
* @return string ViewVC URL | ||
*/ | ||
protected function url_base( $p_repo, $p_file = '', $p_opts=array() ) { | ||
$t_name = urlencode( $this->get_viewvc_name( $p_repo ) ); | ||
$t_root_as_url = $this->get_viewvc_root_as_url( $p_repo ); | ||
|
||
$t_url = rtrim( $this->get_viewvc_url( $p_repo ), '/' ); | ||
|
||
if( $t_root_as_url ) { | ||
$t_url_name = '/'.$t_name; | ||
} else { | ||
$t_url_name = ''; | ||
$p_opts['root']=$t_name; | ||
} | ||
|
||
return $t_url . $t_url_name . $p_file . '?' . http_build_query( $p_opts ); | ||
} | ||
|
||
public function url_repo( $p_repo, $p_changeset=null ) { | ||
$t_opts = array(); | ||
|
||
if ( !is_null( $p_changeset ) ) { | ||
$t_opts['revision'] = $p_changeset->revision; | ||
} | ||
|
||
return $this->url_base( $p_repo, '', $t_opts); | ||
} | ||
|
||
public function url_changeset( $p_repo, $p_changeset ) { | ||
$t_rev = $p_changeset->revision; | ||
$t_opts = array(); | ||
$t_opts['view'] = 'revision'; | ||
$t_opts['revision'] = $t_rev; | ||
|
||
return $this->url_base( $p_repo, '', $t_opts ); | ||
} | ||
|
||
public function url_file( $p_repo, $p_changeset, $p_file ) { | ||
|
||
# if the file has been removed, it doesn't exist in current revision | ||
# so we generate a link to (current revision - 1) | ||
$t_revision = ($p_file->action == 'rm') | ||
? $p_changeset->revision - 1 | ||
: $p_changeset->revision; | ||
$t_use_checkout = $this->get_viewvc_use_checkout( $p_repo ); | ||
|
||
$t_opts = array(); | ||
$t_opts['revision'] = $t_revision; | ||
|
||
if( !$t_use_checkout ) | ||
{ | ||
$t_opts['view'] = 'markup'; | ||
} | ||
|
||
return $this->url_base( $p_repo, $p_file->filename, $t_opts ); | ||
} | ||
|
||
public function url_diff( $p_repo, $p_changeset, $p_file ) { | ||
if ( $p_file->action == 'rm' || $p_file->action == 'add' ) { | ||
return ''; | ||
} | ||
|
||
$t_opts = array(); | ||
$t_opts['r1'] = $p_changeset->revision; | ||
$t_opts['r2'] = $p_changeset->revision - 1; | ||
|
||
return $this->url_base( $p_repo, $p_file->filename, $t_opts ); | ||
} | ||
|
||
public function update_repo_form( $p_repo ) { | ||
$t_url = $this->get_viewvc_url( $p_repo ); | ||
$t_name = $this->get_viewvc_name( $p_repo ); | ||
$t_use_checkout = $this->get_viewvc_use_checkout( $p_repo ); | ||
$t_root_as_url = $this->get_viewvc_root_as_url( $p_repo ); | ||
|
||
?> | ||
<tr <?php echo helper_alternate_class() ?>> | ||
<td class="category"><?php echo lang_get( 'plugin_SourceViewVC_viewvc_url' ) ?></td> | ||
<td><input name="viewvc_url" maxlength="250" size="40" value="<?php echo string_attribute( $t_url ) ?>"/></td> | ||
</tr> | ||
<tr <?php echo helper_alternate_class() ?>> | ||
<td class="category"><?php echo lang_get( 'plugin_SourceViewVC_viewvc_name' ) ?></td> | ||
<td><input name="viewvc_name" maxlength="250" size="40" value="<?php echo string_attribute( $t_name ) ?>"/></td> | ||
</tr> | ||
<tr <?php echo helper_alternate_class() ?>> | ||
<td class="category"><?php echo lang_get( 'plugin_SourceViewVC_viewvc_root_as_url' ) ?></td> | ||
<td><input name="viewvc_root_as_url" type="checkbox" <?php echo ($t_root_as_url ? 'checked="checked"' : '') ?>/></td> | ||
</tr> | ||
<tr <?php echo helper_alternate_class() ?>> | ||
<td class="category"><?php echo lang_get( 'plugin_SourceViewVC_viewvc_use_checkout' ) ?></td> | ||
<td><input name="viewvc_use_checkout" type="checkbox" <?php echo ($t_use_checkout ? 'checked="checked"' : '') ?>/></td> | ||
</tr> | ||
<?php | ||
|
||
return parent::update_repo_form( $p_repo ); | ||
} | ||
|
||
public function update_repo( $p_repo ) { | ||
|
||
$p_repo->info['viewvc_url'] = gpc_get_string( 'viewvc_url' ); | ||
$p_repo->info['viewvc_name'] = gpc_get_string( 'viewvc_name' ); | ||
$p_repo->info['viewvc_use_checkout'] = gpc_get_bool( 'viewvc_use_checkout', false ); | ||
$p_repo->info['viewvc_root_as_url'] = gpc_get_bool( 'viewvc_root_as_url', false ); | ||
|
||
return parent::update_repo( $p_repo ); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?php | ||
|
||
# Copyright (c) 2012 John Reese | ||
# Licensed under the MIT license | ||
|
||
$s_plugin_SourceViewVC_ = ''; | ||
$s_plugin_SourceViewVC_title = 'Subversion / ViewVC Integration'; | ||
$s_plugin_SourceViewVC_description = 'Adds Subversion integration to the Source plugin framework using the ViewVC app.'; | ||
|
||
$s_plugin_SourceViewVC_svn = 'ViewVC'; | ||
$s_plugin_SourceViewVC_viewvc_url = 'ViewVC URL<br/><span class="small">(With trailing slash)</span>'; | ||
$s_plugin_SourceViewVC_viewvc_name = 'ViewVC Name<br/><span class="small">(Repository directory)</span>'; | ||
$s_plugin_SourceViewVC_viewvc_root_as_url = 'ViewVC Root As URL Component Enabled?'; | ||
$s_plugin_SourceViewVC_viewvc_use_checkout = 'ViewVC Checkout View Enabled?'; | ||
|
||
$s_plugin_SourceViewVC_svn_username = 'SVN Username'; | ||
$s_plugin_SourceViewVC_svn_password = 'SVN Password'; | ||
$s_plugin_SourceViewVC_standard_repo = 'Standard Repository<br/><span class="small">(trunk/branches/tags)</span>'; | ||
$s_plugin_SourceViewVC_trunk_path = 'Trunk Path<br/><span class="small">(Non-standard repository)</span>'; | ||
$s_plugin_SourceViewVC_branch_path = 'Branch Path<br/><span class="small">(Non-standard repository)</span>'; | ||
$s_plugin_SourceViewVC_tag_path = 'Tag Path<br/><span class="small">(Non-standard repository)</span>'; | ||
$s_plugin_SourceViewVC_ignore_paths = 'Ignore Other Paths<br/><span class="small">(Non-standard repository)</span>'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
# SourceViewVC Configuration | ||
|
||
## Description | ||
|
||
The **SourceViewVC** extension plugin adds support for SVN repositories | ||
with a [ViewVC](http://www.viewvc.org/) front-end. | ||
|
||
## Requirements | ||
|
||
The **SourceViewVC** plugin requires Mantis 1.2.16. See the | ||
[README](../README.md#requirements) for further information. | ||
|
||
Ensure that all of the following plugins are installed: | ||
* **Source** | ||
* **SourceSVN** | ||
* **SourceViewVC** | ||
See the [README](../README.md#installation) for overall instructions. | ||
|
||
## Configuration | ||
|
||
1. Click the *Repositories* link in the navigation bar. | ||
|
||
2. In the *Create Repository* section: | ||
|
||
- Enter the repository name in the *Name* text field. | ||
- Select *ViewVC* from the *Type* pop-up menu. | ||
- Click the *Create Repository* button. | ||
|
||
3. This will take you to the *Update Repository* page where you'll need to fill | ||
in all the details for the repository: | ||
|
||
- The *Name* field should be pre-populated with the name you entered in Step | ||
2a above. | ||
|
||
- Paste in the SVN repository's URL in the *URL* field | ||
(e.g. `https://localhost.localdomain/repos/myrepo` or | ||
`file:///var/repos/myrepo`). | ||
|
||
- Paste in the ViewVC installation's root URL in the *ViewVC URL* field | ||
(e.g. `http://viewvc-server/viewvc/`). | ||
|
||
- Enter the name of the SVN repository, as it appears in the list seen in | ||
ViewVC, in the *ViewVC Name* field | ||
(e.g. `myrepo`). | ||
|
||
- If the ViewVC installation has the `root_as_url_component` option enabled | ||
(see the `viewvc.conf` file) then enable the *ViewVC Root As URL Component | ||
Enabled?* field. | ||
|
||
- If the ViewVC installation has the checkout view enabled (the | ||
`allowed_views` field list includes `co` in the `viewvc.conf` file) then | ||
enable the *ViewVC Checkout View Enabled?* field. | ||
|
||
- Enter the username of a user which has read access to the SVN repository in | ||
the *SVN Username* field (e.g. "repo-user"). | ||
|
||
- Enter the password for the user in the *SVN Password* field | ||
(e.g. "Sup4rSecre7"). | ||
|
||
- If your repository is configured with the standard `trunk`, `branches` & | ||
`tags` folders at the top-level, select the *Standard Repository* field, | ||
otherwise enter the appropriate paths into the *Trunk Path*, *Branch Path* | ||
and *Tag Path* fields. | ||
|
||
- Click the *Update Repository* button. | ||
|
||
4. Click the *Import Everything* button to test connectivity and perform an | ||
initial import of the repository changesets. | ||
|
||
**Note:** This may take a long time or even fail for large repositories. |