diff --git a/SourceGitphp/LICENSE b/SourceGitphp/LICENSE new file mode 100644 index 000000000..ab2c13220 --- /dev/null +++ b/SourceGitphp/LICENSE @@ -0,0 +1,23 @@ +Copyright (c) 2012 John Reese + +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. + diff --git a/SourceGitphp/SourceGitphp.php b/SourceGitphp/SourceGitphp.php new file mode 100644 index 000000000..9f614d85d --- /dev/null +++ b/SourceGitphp/SourceGitphp.php @@ -0,0 +1,367 @@ +name = plugin_lang_get( 'title' ); + $this->description = plugin_lang_get( 'description' ); + + $this->version = '0.10'; + $this->requires = array( + 'MantisCore' => '1.2.0', + 'Source' => '0.16', + ); + + $this->author = 'John Reese'; + $this->contact = 'john@noswap.com'; + $this->url = 'http://noswap.com'; + } + + public $type = 'gitphp'; + + public function show_type() { + return plugin_lang_get( 'gitphp' ); + } + + public function show_changeset( $p_repo, $p_changeset ) { + $t_ref = substr( $p_changeset->revision, 0, 8 ); + $t_branch = $p_changeset->branch; + + return "$t_branch $t_ref"; + } + + public function show_file( $p_repo, $p_changeset, $p_file ) { + return "$p_file->action - $p_file->filename"; + } + + private function uri_base( $p_repo ) { + $t_uri_base = $p_repo->info['gitphp_root'] . '?p=' . $p_repo->info['gitphp_project'] . '&'; + return $t_uri_base; + } + + public function url_repo( $p_repo, $t_changeset=null ) { + return $this->uri_base( $p_repo ) . ( $t_changeset ? 'h=' . $t_changeset->revision : '' ); + } + + public function url_changeset( $p_repo, $p_changeset ) { + return $this->uri_base( $p_repo ) . 'a=commitdiff&h=' . $p_changeset->revision; + } + + public function url_file( $p_repo, $p_changeset, $p_file ) { + return $this->uri_base( $p_repo ) . 'a=blob&f=' . $p_file->filename . + '&h=' . $p_file->revision . '&hb=' . $p_changeset->revision; + } + + public function url_diff( $p_repo, $p_changeset, $p_file ) { + return $this->uri_base( $p_repo ) . 'a=blobdiff&f=' . $p_file->filename . + '&h=' . $p_file->revision . '&hb=' . $p_changeset->revision . '&hp=' . $p_changeset->parent; + } + + public function update_repo_form( $p_repo ) { + $t_gitphp_root = null; + $t_gitphp_project = null; + + if ( isset( $p_repo->info['gitphp_root'] ) ) { + $t_gitphp_root = $p_repo->info['gitphp_root']; + } + + if ( isset( $p_repo->info['gitphp_project'] ) ) { + $t_gitphp_project = $p_repo->info['gitphp_project']; + } + + if ( isset( $p_repo->info['master_branch'] ) ) { + $t_master_branch = $p_repo->info['master_branch']; + } else { + $t_master_branch = 'master'; + } +?> +
';
+ $t_branch = $p_repo->info['master_branch'];
+ if ( is_blank( $t_branch ) ) {
+ $t_branch = 'master';
+ }
+
+ if ($t_branch != '*')
+ {
+ $t_branches = array_map( 'trim', explode( ',', $t_branch ) );
+ }
+ else
+ {
+ $t_heads_url = $this->uri_base( $p_repo ) . 'a=heads';
+ $t_branches_input = url_get( $t_heads_url );
+
+ $t_branches_input = str_replace( array("\r", "\n", '<', '>', ' '), array('', '', '<', '>', ' '), $t_branches_input );
+
+ $t_branches_input_p1 = strpos( $t_branches_input, '