[Codestriker-commits] CVS update: codestriker/lib/Codestriker/TopicListeners Email.pm
Brought to you by:
sits
|
From: <si...@us...> - 2006-01-15 21:20:24
|
Created Codestriker topic at: http://codestriker.sourceforge.net/cgi-bin/codestriker.pl?topic=4859195&action=view User: sits Date: 06/01/15 13:20:06 Modified: . CHANGELOG README codestriker.conf doc codestriker.sgml lib Codestriker.pm lib/Codestriker/Action CreateTopic.pm EditComment.pm SubmitEditTopicProperties.pm SubmitNewComment.pm SubmitNewTopic.pm ViewTopicFile.pm ViewTopicProperties.pm lib/Codestriker/TopicListeners Email.pm Log: Created a new optional configuration parameter $repository_name_map in codestriker.conf. This allows for a user-defined repository name to be displayed in the codestriker UI, rather than the full repository URL. This can be useful for hiding potentially sensitive username/password information that might be a part of the repository URL. See the codestriker.conf file for more information. Submitted by Edwin Fine <edw...@ve...>. Index: CHANGELOG =================================================================== RCS file: /cvsroot/codestriker/codestriker/CHANGELOG,v retrieving revision 1.178 retrieving revision 1.179 diff -u -r1.178 -r1.179 --- CHANGELOG 7 Jan 2006 03:20:06 -0000 1.178 +++ CHANGELOG 15 Jan 2006 21:19:59 -0000 1.179 @@ -3,6 +3,14 @@ Version 1.9.2 +* Created a new optional configuration parameter $repository_name_map + in codestriker.conf. This allows for a user-defined repository name + to be displayed in the codestriker UI, rather than the full + repository URL. This can be useful for hiding potentially sensitive + username/password information that might be a part of the repository + URL. See the codestriker.conf file for more information. + Submitted by Edwin Fine <edw...@ve...>. + * Fixed problem with Subversion repositories on Win32, where Codestriker was unable to launch the svn program. Index: README =================================================================== RCS file: /cvsroot/codestriker/codestriker/README,v retrieving revision 1.49 retrieving revision 1.50 diff -u -r1.49 -r1.50 --- README 7 Sep 2004 21:56:20 -0000 1.49 +++ README 15 Jan 2006 21:19:59 -0000 1.50 @@ -1,5 +1,5 @@ Codestriker -Copyright (c) 2001, 2002, 2003, 2004 David Sitsky. All rights reserved. +Copyright (c) 2001 - 2006 David Sitsky. All rights reserved. si...@us... *** Please read the CHANGELOG file for details on changes *** Index: codestriker.conf =================================================================== RCS file: /cvsroot/codestriker/codestriker/codestriker.conf,v retrieving revision 1.78 retrieving revision 1.79 diff -u -r1.78 -r1.79 --- codestriker.conf 27 Jul 2005 10:50:57 -0000 1.78 +++ codestriker.conf 15 Jan 2006 21:19:59 -0000 1.79 @@ -161,6 +161,19 @@ 'clearcase:c:\\stuff\\view_name\\vob_name' ); +# A mapping of repository URLs to names. In any screen where a +# repository is displayed, if there is a mapping for the repository +# defined here, then the symbolic name will be displayed instead of +# its raw URL. This is useful when the URL contains sensitive +# username/password information, or the symbolic name is more +# meaningful to the end-user. If there is no mapping defined for a +# specific repository, its URL will be displayed. +$repository_name_map = +{ + '/home/sits/cvs' => 'Local CVS', + ':pserver:sits:pas...@cv...:/cvsroot' => 'SF CVS' +}; + # A mapping of repositories to filename viewers. Examples of such systems # would be CVSweb and ViewCVS, for local repositories. Mappings are # not required for remote CVSweb and ViewCVS repositories, as they are Index: codestriker.sgml =================================================================== RCS file: /cvsroot/codestriker/codestriker/doc/codestriker.sgml,v retrieving revision 1.50 retrieving revision 1.51 diff -u -r1.50 -r1.51 --- codestriker.sgml 19 Jun 2005 10:56:00 -0000 1.50 +++ codestriker.sgml 15 Jan 2006 21:20:04 -0000 1.51 @@ -7,9 +7,9 @@ <book> <bookinfo> <title>The Codestriker Guide</title> - <subtitle>Version 1.9.0</subtitle> + <subtitle>Version 1.9.2</subtitle> <legalnotice> - <para>Copyright (c) 2001, 2002, 2003, 2004</para> + <para>Copyright (c) 2001 - 2006</para> </legalnotice> <authorgroup> <author> @@ -517,6 +517,27 @@ </programlisting> </para> <para> + As explained by the comment in the codestriker.conf file, + sometimes there is a benefit for displaying a name instead of + a repository URL in the Codestriker UI. + <programlisting> +# A mapping of repository URLs to names. In any screen where a +# repository is displayed, if there is a mapping for the repository +# defined here, then the symbolic name will be displayed instead of +# its raw URL. This is useful when the URL contains sensitive +# username/password information, or the symbolic name is more +# meaningful to the end-user. If there is no mapping defined for a +# specific repository, its URL will be displayed. +$repository_name_map = +{ + '/home/sits/cvs' => 'Local CVS', + ':pserver:sits:pas...@cv...:/cvsroot' => 'SF CVS' +}; + + </programlisting> + </para> + + <para> During a review, it is sometimes beneficial to see the revision history of a file, such as information provided by CVSweb or ViewCVS. You can specify a mapping of repository Index: Codestriker.pm =================================================================== RCS file: /cvsroot/codestriker/codestriker/lib/Codestriker.pm,v retrieving revision 1.80 retrieving revision 1.81 diff -u -r1.80 -r1.81 --- Codestriker.pm 5 Oct 2005 07:56:10 -0000 1.80 +++ Codestriker.pm 15 Jan 2006 21:20:04 -0000 1.81 @@ -23,7 +23,8 @@ $allow_delete $allow_searchlist $default_file_to_view $allow_projects $antispam_email $VERSION $title $BASEDIR $metric_config $tmpdir @metric_schema $comment_state_metrics - $project_states $rss_enabled + $project_states $rss_enabled $repository_name_map $repository_url_map + @valid_repository_names ); # Version of Codestriker. @@ -306,6 +307,25 @@ { do "$BASEDIR/codestriker_test.conf"; } + + # Fill in $repository_name_map for those repository entries which don't have + # a mapping, with the same value as the repository value itself. + foreach my $repository (@valid_repositories) { + if (! exists $repository_name_map->{$repository}) { + $repository_name_map->{$repository} = $repository; + } + } + + # Define the equivalent list of valid repository names. + @valid_repository_names = (); + foreach my $repository (@valid_repositories) { + push @valid_repository_names, $repository_name_map->{$repository}; + } + + # Define the reverse mapping now for convenience. + foreach my $key (keys %${repository_name_map}) { + $repository_url_map->{$repository_name_map->{$key}} = $key; + } } # Returns the current time in a format suitable for a DBI timestamp value. Index: CreateTopic.pm =================================================================== RCS file: /cvsroot/codestriker/codestriker/lib/Codestriker/Action/CreateTopic.pm,v retrieving revision 1.28 retrieving revision 1.29 diff -u -r1.28 -r1.29 --- CreateTopic.pm 15 Feb 2005 10:11:50 -0000 1.28 +++ CreateTopic.pm 15 Jan 2006 21:20:05 -0000 1.29 @@ -57,15 +57,15 @@ # Set the default repository to select. if (! (defined $vars->{'default_repository'}) || $vars->{'default_repository'} eq "") { - if ($#Codestriker::valid_repositories != -1) { + if ($#Codestriker::valid_repository_names != -1) { # Choose the first repository as the default selection. $vars->{'default_repository'} = - $Codestriker::valid_repositories[0]; + $Codestriker::valid_repository_names[0]; } } # Indicate the list of valid repositories which can be choosen. - $vars->{'repositories'} = \@Codestriker::valid_repositories; + $vars->{'repositories'} = \@Codestriker::valid_repository_names; # Read the list of projects available to make that choice available # when a topic is created. Index: EditComment.pm =================================================================== RCS file: /cvsroot/codestriker/codestriker/lib/Codestriker/Action/EditComment.pm,v retrieving revision 1.13 retrieving revision 1.14 diff -u -r1.13 -r1.14 --- EditComment.pm 1 Mar 2005 10:12:49 -0000 1.13 +++ EditComment.pm 15 Jan 2006 21:20:05 -0000 1.14 @@ -48,7 +48,7 @@ email=>$email, mode=>$mode, tabwidth=>$tabwidth, - repository=>$topic->{repository}, + repository=>$Codestriker::repository_name_map->{$topic->{repository}}, reload=>0, cache=>0); # Create the hash for the template variables. Index: SubmitEditTopicProperties.pm =================================================================== RCS file: /cvsroot/codestriker/codestriker/lib/Codestriker/Action/SubmitEditTopicProperties.pm,v retrieving revision 1.10 retrieving revision 1.11 diff -u -r1.10 -r1.11 --- SubmitEditTopicProperties.pm 21 Nov 2004 05:00:08 -0000 1.10 +++ SubmitEditTopicProperties.pm 15 Jan 2006 21:20:05 -0000 1.11 @@ -33,7 +33,7 @@ my $cc = $http_input->get('cc'); my $topic_state = $http_input->get('topic_state'); my $bug_ids = $http_input->get('bug_ids'); - my $repository_url = $http_input->get('repository'); + my $repository_name = $http_input->get('repository'); my $projectid = $http_input->get('projectid'); # Check if this action is allowed, and that the state is valid. @@ -80,6 +80,13 @@ $cc = $topic->{cc}; } + # Make sure the repository value is correct. + my $repository_url = $Codestriker::repository_url_map->{$repository_name}; + if ($repository_url eq "") { + $feedback .= "Repository name \"$repository_name\" is unknown.\n" . + "Update your codestriker.conf file with this entry.\n"; + } + if ($feedback eq "") { if ($topic_state eq "Deleted") { $rc = $topic->delete(); Index: SubmitNewComment.pm =================================================================== RCS file: /cvsroot/codestriker/codestriker/lib/Codestriker/Action/SubmitNewComment.pm,v retrieving revision 1.8 retrieving revision 1.9 diff -u -r1.8 -r1.9 --- SubmitNewComment.pm 13 Jun 2005 22:30:11 -0000 1.8 +++ SubmitNewComment.pm 15 Jan 2006 21:20:05 -0000 1.9 @@ -93,7 +93,7 @@ topic_title=>"Comment Submitted: " . "$topic->{title}", email=>$email, - repository=>$topic->{repository}, + repository=>$Codestriker::repository_name_map->{$topic->{repository}}, load_anchor=>$anchor, reload=>$reload, cache=>0); Index: SubmitNewTopic.pm =================================================================== RCS file: /cvsroot/codestriker/codestriker/lib/Codestriker/Action/SubmitNewTopic.pm,v retrieving revision 1.20 retrieving revision 1.21 diff -u -r1.20 -r1.21 --- SubmitNewTopic.pm 16 Dec 2004 03:40:46 -0000 1.20 +++ SubmitNewTopic.pm 15 Jan 2006 21:20:05 -0000 1.21 @@ -36,7 +36,7 @@ my $topic_file = $http_input->get('fh_filename'); my $fh_mime_type = $http_input->get('fh_mime_type'); my $bug_ids = $http_input->get('bug_ids'); - my $repository_url = $http_input->get('repository'); + my $repository_name = $http_input->get('repository'); my $projectid = $http_input->get('projectid'); my $project_name = $http_input->get('project_name'); my $start_tag = $http_input->get('start_tag'); @@ -85,7 +85,7 @@ $http_response->generate_header(topic_title=>"Create New Topic", email=>$email, reviewers=>$reviewers, - cc=>$cc, repository=>$repository_url, + cc=>$cc, repository=>$repository_name, projectid=>$projectid, reload=>0, cache=>0); @@ -101,7 +101,7 @@ $error_vars->{'topic_description'} = $topic_description; $error_vars->{'topic_title'} = $topic_title; $error_vars->{'bug_ids'} = $bug_ids; - $error_vars->{'default_repository'} = $repository_url; + $error_vars->{'default_repository'} = $repository_name; $error_vars->{'repositories'} = \@Codestriker::valid_repositories; $error_vars->{'start_tag'} = $start_tag; $error_vars->{'end_tag'} = $end_tag; @@ -110,27 +110,25 @@ $error_vars->{'default_to_head'} = $default_to_head; my $repository = undef; + my $repository_url = undef; if (scalar(@Codestriker::valid_repositories)) { # Set the repository to the default if it is not entered. - if ($repository_url eq "" || scalar(@Codestriker::valid_repositories) == 1) { - $repository_url = $Codestriker::valid_repositories[0]; + if ($repository_name eq "" || scalar(@Codestriker::valid_repository_names) == 1) { + $repository_name = $Codestriker::valid_repository_names[0]; } # Check if the repository argument is in fact a configured # repository. - my $configured = 0; - foreach my $rep ( @Codestriker::valid_repositories ) { - $configured = 1 if $repository_url eq $rep; - } + $repository_url = $Codestriker::repository_url_map->{$repository_name}; - if ($configured) { - $repository = - Codestriker::Repository::RepositoryFactory->get($repository_url); + if (defined $repository_url) { + $repository = + Codestriker::Repository::RepositoryFactory->get($repository_url); } if (! defined $repository) { $feedback .= - "The repository value \"$repository_url\" is invalid.\n" . + "The repository value set for \"$repository_name\" is invalid.\n" . "Please correct this value in your codestriker.conf file, " . "and try again.\n"; } @@ -195,8 +193,10 @@ if ($rc == $Codestriker::DIFF_TOO_BIG) { $feedback .= "Generated diff file is too big.\n"; } elsif ($rc == $Codestriker::UNSUPPORTED_OPERATION) { - $feedback .= "Repository \"" . $repository->toString() . + $feedback .= "Repository \"" . $repository_name . "\" does not support tag retrieval, you have to use the text file upload.\n"; + } elsif ($rc != $Codestriker::OK) { + $feedback .= "Unexpected error $rc retrieving diff text.\n"; } # Seek to the beginning of the temporary file so it can be parsed. Index: ViewTopicFile.pm =================================================================== RCS file: /cvsroot/codestriker/codestriker/lib/Codestriker/Action/ViewTopicFile.pm,v retrieving revision 1.11 retrieving revision 1.12 diff -u -r1.11 -r1.12 --- ViewTopicFile.pm 1 Mar 2005 10:12:49 -0000 1.11 +++ ViewTopicFile.pm 15 Jan 2006 21:20:05 -0000 1.12 @@ -100,7 +100,7 @@ mode=>$mode, tabwidth=>$tabwidth, fview=>$fview, - repository=>$topic->{repository}, + repository=>$Codestriker::repository_name_map->{$topic->{repository}}, reload=>0, cache=>1); # Render the HTML header. Index: ViewTopicProperties.pm =================================================================== RCS file: /cvsroot/codestriker/codestriker/lib/Codestriker/Action/ViewTopicProperties.pm,v retrieving revision 1.12 retrieving revision 1.13 diff -u -r1.12 -r1.13 --- ViewTopicProperties.pm 1 Mar 2005 10:12:49 -0000 1.12 +++ ViewTopicProperties.pm 15 Jan 2006 21:20:05 -0000 1.13 @@ -95,8 +95,8 @@ # Indicate what repositories are available, and what the topic's # repository is. - $vars->{'topic_repository'} = $topic->{repository}; - $vars->{'repositories'} = \@Codestriker::valid_repositories; + $vars->{'topic_repository'} = $Codestriker::repository_name_map->{$topic->{repository}}; + $vars->{'repositories'} = \@Codestriker::valid_repository_names; # Indicate what projects are available, and what the topic's project is. my @projects = Codestriker::Model::Project->list(); Index: Email.pm =================================================================== RCS file: /cvsroot/codestriker/codestriker/lib/Codestriker/TopicListeners/Email.pm,v retrieving revision 1.14 retrieving revision 1.15 diff -u -r1.14 -r1.15 --- Email.pm 30 Jan 2005 00:48:11 -0000 1.14 +++ Email.pm 15 Jan 2006 21:20:06 -0000 1.15 @@ -218,7 +218,8 @@ # Check for repository change. if ($topic->{repository} ne $topic_orig->{repository}) { - $changes .= "The repository was changed to $topic->{repository}.\n"; + my $value = $Codestriker::repository_name_map->{$topic->{repository}}; + $changes .= "The repository was changed to $value.\n"; } # Check for description change. |