Skip to content

Commit d06e9b4

Browse files
committed
New SourceVisualSVNServer plugin
Add file and diff link button support for linking to the built-in web front-end for VisualSVN Server. Thanks to David Hopkins, FBR Ltd. Fixes PR #313
2 parents 97e9217 + 2a056f7 commit d06e9b4

File tree

7 files changed

+254
-0
lines changed

7 files changed

+254
-0
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,6 @@
55
*.buildpath
66
*.project
77
*.idea
8+
.vs
9+
.svn
10+
*.DotSettings.user

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ plugins:
3939
* **SourceSVN**: SVN repositories locally accessible by the SVN binaries.
4040
* **SourceViewVC**: SVN repositories accessible via a
4141
[ViewVC](http://www.viewvc.org/) web frontend installation.
42+
* **SourceVisualSVNServer**: SVN repositories hosted on a
43+
[VisualSVN Server](https://www.visualsvn.com/server/) installation,
44+
with support for URL linking from MantisBT to VisualSVN Server's built-in web frontend.
4245
* **SourceWebSVN**: SVN repositories accessible via a
4346
[WebSVN](http://www.websvn.info/) web frontend installation.
4447

@@ -120,6 +123,7 @@ MantisBT version | Tags | Branch | Notes
120123
* [SourceGitlab](SourceGitlab/README.md)
121124
* [SourceViewVC](docs/CONFIGURING.SourceViewVC.md)
122125
* [SourceSVN](docs/CONFIGURING.SourceSVN.md)
126+
* [SourceVisualSVNServer](docs/CONFIGURING.SourceVisualSVNServer.md)
123127

124128
9. Once configured, click the "Return to Repository" link and click either
125129
the "Import Everything" or "Import Newest Data" button to perform initial

SourceVisualSVNServer/LICENSE

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
Copyright (c) 2019 David Hopkins, FBR Ltd
2+
3+
Permission is hereby granted, free of charge, to any person
4+
obtaining a copy of this software and associated documentation
5+
files (the "Software"), to deal in the Software without
6+
restriction, including without limitation the rights to use,
7+
copy, modify, merge, publish, distribute, sublicense, and/or sell
8+
copies of the Software, and to permit persons to whom the
9+
Software is furnished to do so, subject to the following
10+
conditions:
11+
12+
The above copyright notice and this permission notice shall be
13+
included in all copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
17+
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
19+
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
20+
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21+
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22+
OTHER DEALINGS IN THE SOFTWARE.
23+
Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
<?php
2+
3+
# Copyright (c) 2019 David Hopkins, FBR Ltd
4+
# Copyright (c) 2015 John Bailey
5+
# Copyright (c) 2012 John Reese
6+
# Licensed under the MIT license
7+
8+
if ( false === include_once( config_get( 'plugin_path' ) . 'SourceSVN/SourceSVN.php' ) ) {
9+
return;
10+
}
11+
12+
class SourceVisualSVNServerPlugin extends SourceSVNPlugin {
13+
14+
const PLUGIN_VERSION = '2.0.2';
15+
const FRAMEWORK_VERSION_REQUIRED = '2.0.0';
16+
const SOURCESVN_VERSION_REQUIRED = '2.0.0';
17+
18+
public function register() {
19+
$this->name = plugin_lang_get( 'title' );
20+
$this->description = plugin_lang_get( 'description' );
21+
22+
$this->version = self::PLUGIN_VERSION;
23+
$this->requires = array(
24+
'MantisCore' => self::MANTIS_VERSION,
25+
'Source' => self::FRAMEWORK_VERSION_REQUIRED,
26+
'SourceSVN' => self::SOURCESVN_VERSION_REQUIRED,
27+
);
28+
29+
$this->author = 'David Hopkins';
30+
$this->contact = 'david.hopkins@fbr.com.au';
31+
$this->url = 'https://github.com/mantisbt-plugins/source-integration';
32+
}
33+
34+
public $type = 'vsvns';
35+
36+
public function show_type() {
37+
return plugin_lang_get( 'vsvns' );
38+
}
39+
40+
public function get_visualsvnserver_url_prefix( $p_repo ) {
41+
return isset( $p_repo->info['visualsvnserver_url_prefix'] )
42+
? $p_repo->info['visualsvnserver_url_prefix']
43+
: 'svn'; # Match VisualSVN Server default configuration
44+
}
45+
46+
/**
47+
* Builds the VisualSVNServer URL base string
48+
* @param object $p_repo repository
49+
* @return string VisualSVNServer URL
50+
*/
51+
protected function url_base( $p_repo ) {
52+
# VisualSVN Server web interface is always on the same host name
53+
# as the HTTP(S)-served repositories, accessed via the /!/#reponame path
54+
$t_repo_url = parse_url( $p_repo->url );
55+
$t_repo_path = $t_repo_url['path'];
56+
57+
$t_url_prefix = $this->get_visualsvnserver_url_prefix( $p_repo );
58+
59+
# Strip repo prefix (typically '/svn/') from path
60+
$t_prefix = empty( $t_url_prefix ) ? '/' : '/' . urlencode( $t_url_prefix ) . '/';
61+
if( substr( $t_repo_path, 0, strlen( $t_prefix ) ) == $t_prefix ) {
62+
$t_repo_path = substr( $t_repo_path, strlen( $t_prefix ) );
63+
}
64+
65+
# Only include port in final URL if it was present originally
66+
$t_port = isset( $t_repo_url['port'] ) ? ':' . $t_repo_url['port'] : '';
67+
68+
$t_url = $t_repo_url['scheme'] . '://' . $t_repo_url['host'] . $t_port . '/!/#' . $t_repo_path;
69+
return $t_url;
70+
}
71+
72+
public function url_repo( $p_repo, $p_changeset = null ) {
73+
$t_url = $this->url_base( $p_repo );
74+
75+
if( !is_null( $p_changeset ) ) {
76+
$t_revision = $p_changeset->revision;
77+
$t_url .= '/view/r' . urlencode( $t_revision ) . '/';
78+
}
79+
80+
return $t_url;
81+
}
82+
83+
public function url_changeset( $p_repo, $p_changeset ) {
84+
$t_repo_url = $this->url_base( $p_repo );
85+
$t_revision = $p_changeset->revision;
86+
87+
$t_url = $t_repo_url . '/commit/r' . urlencode( $t_revision ) . '/';
88+
return $t_url;
89+
}
90+
91+
public function url_file( $p_repo, $p_changeset, $p_file ) {
92+
$t_repo_url = $this->url_base( $p_repo );
93+
94+
# if the file has been removed, it doesn't exist in current revision
95+
# so we generate a link to (current revision - 1)
96+
$t_revision = ( $p_file->action == 'rm' )
97+
? $p_changeset->revision - 1
98+
: $p_changeset->revision;
99+
100+
$t_url = $t_repo_url . '/view/r' . urlencode( $t_revision ) . $p_file->filename;
101+
102+
return $t_url;
103+
}
104+
105+
public function url_diff( $p_repo, $p_changeset, $p_file ) {
106+
if( $p_file->action == 'rm' || $p_file->action == 'add' ) {
107+
# Return default no-link for add/remove change diffs
108+
return parent::url_diff( $p_repo, $p_changeset, $p_file );
109+
}
110+
111+
# The web interface for VisualSVN Server displays file diffs as inline content
112+
# when viewing a particular commit.
113+
# It doesn't have a specific page for single-file diffs,
114+
# at least as of v3.9.5, 2019-04-29
115+
$t_url = $this->url_changeset( $p_repo, $p_changeset );
116+
return $t_url;
117+
}
118+
119+
public function update_repo_form( $p_repo ) {
120+
$t_url_prefix = $this->get_visualsvnserver_url_prefix( $p_repo );
121+
?>
122+
<tr>
123+
<td class="category"><?php echo plugin_lang_get( 'visualsvnserver_url_prefix' ) ?></td>
124+
<td>
125+
<input type="text" name="visualsvnserver_url_prefix" maxlength="250" size="40"
126+
value="<?php echo string_attribute( $t_url_prefix ) ?>"
127+
/>
128+
</td>
129+
</tr>
130+
<?php
131+
return parent::update_repo_form( $p_repo );
132+
}
133+
134+
public function update_repo( $p_repo ) {
135+
$p_repo->info['visualsvnserver_url_prefix'] = gpc_get_string( 'visualsvnserver_url_prefix' );
136+
137+
return parent::update_repo( $p_repo );
138+
}
139+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?php
2+
# Copyright (c) 2019 David Hopkins, FBR Ltd
3+
# Copyright (c) 2012 John Reese
4+
# Licensed under the MIT license
5+
6+
$s_plugin_SourceVisualSVNServer_ = '';
7+
$s_plugin_SourceVisualSVNServer_vsvns = 'VisualSVN Server';
8+
$s_plugin_SourceVisualSVNServer_title = 'Source VisualSVN Server Integration';
9+
$s_plugin_SourceVisualSVNServer_description = 'Adds Subversion integration to the Source plugin framework, with hyperlinks to the VisualSVN Server web interface.';
10+
11+
$s_plugin_SourceVisualSVNServer_visualsvnserver_url_prefix = 'VisualSVN Server repository URL prefix<br/><span class="small">(Default "svn")</span>';
12+
13+
$s_plugin_SourceVisualSVNServer_svn_username = 'SVN Username<br/><span class="small">(Ignored under Integrated Windows Authentication)</span>';
14+
$s_plugin_SourceVisualSVNServer_svn_password = 'SVN Password<br/><span class="small">(Ignored under Integrated Windows Authentication)</span>';
15+
$s_plugin_SourceVisualSVNServer_standard_repo = 'Standard Repository<br/><span class="small">(trunk/branches/tags)</span>';
16+
$s_plugin_SourceVisualSVNServer_trunk_path = 'Trunk Path<br/><span class="small">(Non-standard repository)</span>';
17+
$s_plugin_SourceVisualSVNServer_branch_path = 'Branch Path<br/><span class="small">(Non-standard repository)</span>';
18+
$s_plugin_SourceVisualSVNServer_tag_path = 'Tag Path<br/><span class="small">(Non-standard repository)</span>';
19+
$s_plugin_SourceVisualSVNServer_ignore_paths = 'Ignore Other Paths<br/><span class="small">(Non-standard repository)</span>';
20+
21+
$s_plugin_SourceVisualSVNServer_configuration = 'Configuration';
22+
$s_plugin_SourceVisualSVNServer_update = 'Configuration';
23+
$s_plugin_SourceVisualSVNServer_svnpath = 'SVN: Path to binary';
24+
$s_plugin_SourceVisualSVNServer_svnargs = 'SVN: Command arguments';
25+
$s_plugin_SourceVisualSVNServer_svnssl = 'SVN: Trust All SSL Certs<br/><span class="small">(Requires Subversion 1.6 or newer)</span>';
26+
$s_plugin_SourceVisualSVNServer_winstart = 'SVN: Use Windows `start`<br/><span class="small">(Requires a configured path to binary)</span>';
27+
28+
$s_plugin_SourceVisualSVNServer_error_path_invalid = 'Path to Subversion binary is invalid, inaccessible or not a directory.';
29+
$s_plugin_SourceVisualSVNServer_error_svn_run = 'Failed to execute Subversion.';
30+
$s_plugin_SourceVisualSVNServer_error_svn_cmd = 'Subversion execution returned an error: "%1$s".';
31+
32+
$s_plugin_SourceVisualSVNServer_revision_already_committed = 'Revision %s already committed!';
33+
$s_plugin_SourceVisualSVNServer_revprop_detected = ' SVN:LOG revision property change detected.';

docs/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ specification.
1414

1515
### Added
1616

17+
- Support for VisualSVN Server, thanks to David Hopkins, FBR Ltd
18+
[#313](https://github.com/mantisbt-plugins/source-integration/pull/313)
1719
- Default primary branch can be configured for git-based repositories
1820
[#308](https://github.com/mantisbt-plugins/source-integration/issues/308)
1921

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# SourceVisualSVNServer Configuration
2+
3+
## Description
4+
5+
The **SourceVisualSVNServer** extension plugin adds support for
6+
adding links from MantisBT to the VisualSVN Server web interface,
7+
in addition to the basic **SourceSVN** features.
8+
9+
## Requirements
10+
11+
The **SourceVisualSVNServer** plugin requires Mantis 1.2.x. See the
12+
[README](../README.md#requirements) for further information.
13+
14+
Ensure that all of the following plugins are installed:
15+
* **Source**
16+
* **SourceSVN**
17+
* **SourceVisualSVNServer**
18+
19+
See the [README](../README.md#installation) for overall instructions
20+
with regards to installing SourceIntegration plugins.
21+
22+
## Configuration of SVN
23+
24+
See [SourceSVN configuration](CONFIGURING.SourceSVN.md#configuration-of-the-plugin).
25+
26+
## Configuration of a Repository
27+
28+
1. Click the *Repositories* link in the navigation bar.
29+
30+
2. In the *Create Repository* section:
31+
32+
- Enter the repository name in the *Name* text field.
33+
- Select *VisualSVN Server* from the *Type* pop-up menu.
34+
- Click the *Create Repository* button.
35+
36+
3. This will take you to the *Update Repository* page where you'll need to fill
37+
in all the details for the repository:
38+
39+
- The *Name* field should be pre-populated with the name you entered in Step 2a above.
40+
- Paste in the SVN repository's URL in the *URL* field
41+
(e.g. `https://localhost.localdomain/svn/myrepo`).
42+
- Configure the [standard SVN repository settings](CONFIGURING.SourceSVN.md#configuration-of-a-repository).
43+
- If necessary, update the repository URL path prefix to match the configuration of the VisualSVN Server (default `svn`).
44+
The plugin uses this prefix to locate the corresponding web interface URLs for the repository.
45+
- Click the *Update Repository* button.
46+
47+
4. Click the *Import Everything* button to test connectivity and perform an
48+
initial import of the repository changesets.
49+
50+
**Note:** This may take a long time or even fail for large repositories.

0 commit comments

Comments
 (0)