Changeset 10474


Ignore:
Timestamp:
01/04/11 03:42:05 (17 months ago)
Author:
GeorgeClark
Message:

Item9238: Add suport for the git status command.
also Documentation updates.

Location:
trunk/RepositoryPlugin
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/RepositoryPlugin/data/System/RepositoryPlugin.txt

    r10473 r10474  
    2626| =%<nop>REPO{}%= | Provide a git report on the topic expanding the macro | 
    2727| =%<nop>REPO{module="Foswiki::Module"}%= | Provide a git report on the specified Foswiki module. | 
    28 | =%<nop>REPO{web="Someweb" topic="SomeTopic"}%= | Provide a git report on the specified Web.Topic | 
     28| =%<nop>REPO{[web="Someweb"] topic="[Someweb.]SomeTopic"}%= | Provide a git report on the specified Web.Topic | 
     29| =%<nop>REPO{["svninfo" [module=] [topic=]}%= | Provide a =git svn info= report on the repo containing the topic or module | 
     30| =%<nop>REPO{["status" [module=] [topic=]}%= | Provide a =git status= report on the repo containing the topic or module | 
    2931 
    3032---++ Examples 
    3133 
    32 ---+++ Report for this topic 
     34---+++ Report git status for this topic file =%SYSTEMWEB%/%TOPIC%.txt= 
    3335If installed, the ==%<nop>REPO{}%== macro will expand to the status of this topic file - =%WEB%/%TOPIC%.txt=. 
    3436 
    3537%REPO{}% 
    3638 
    37 ---+++ =git svn info= report for this topic's repository 
     39---+++ Report =git svn info= for this topic's repository 
    3840If installed, the ==%<nop>REPO{"svninfo"}%== report will expand to the svn information about the repository that contains this topic. 
    3941 
    4042%REPO{"svninfo"}% 
    4143 
    42 ---+++ Report for Main.WebHome 
    43 The ==%<nop>REPO{web="Main" topic="WebHome"}%== (or alternate form ==%<nop>REPO{topic="Main.WebHome"}%== ) expands to a report on the specified topic file. 
     44---+++ Report git status for the topic file =%USERSWEB%.WebHome.txt= 
     45The ==%<nop>REPO{web="%USERSWEB%" topic="WebHome"}%== (or alternate form ==%<nop>REPO{topic="Main.WebHome"}%== ) expands to a report on the specified topic file. 
    4446 
    4547%REPO{topic="Main.WebHome"}% 
    4648 
    47 ---+++ Report for =Foswiki::Plugins::RepositoryPlugin= 
     49---+++ Report git status for =Foswiki::Plugins::RepositoryPlugin= 
    4850The ==%<nop>REPO{module="Foswiki::Plugins::RepositoryPlugin"}%== provides a report on the Plugin module implementing the %REPO macro. Note that an alternative to [[%SYSTEMWEB%.PerlDoc]] - [[%SYSTEMWEB%.RepoPerlDoc]] is provided with this plugin. 
    4951 
    5052%REPO{module="Foswiki::Plugins::RepositoryPlugin"}% 
     53 
     54---+++ Report =git status= for the repository contatining =Foswiki::Plugins::RepositoryPlugin= 
     55The ==%<nop>REPO{"status" module="Foswiki::Plugins::RepositoryPlugin"}%== provides a report on the Plugin module implementing the %REPO macro. Untracked files are not reported. 
     56 
     57%REPO{"status" module="Foswiki::Plugins::RepositoryPlugin"}% 
    5158 
    5259---++ Installation Instructions 
  • trunk/RepositoryPlugin/lib/Foswiki/Plugins/RepositoryPlugin.pm

    r10473 r10474  
    185185        return $report; 
    186186    } 
    187  
    188     ( my $topicStatus, $exit ) = Foswiki::Sandbox->sysCommand( 
    189         "$gitbin $repoLoc status --porcelain  $absfile ", 
    190     ); 
    191  
    192     $topicStatus = substr( $topicStatus, 0, 2 ); 
    193  
    194     return "*File not known to git:* =$absfile= " if ( $topicStatus eq '??' ); 
    195  
    196     my $status = 
    197         $topicStatus =~ m/\ [MD]/  ? 'Modified, not updated in index' 
    198       : $topicStatus =~ m/M[\ MD]/ ? 'updated in index' 
    199       : $topicStatus =~ m/A[\ MD]/ ? 'added to index' 
    200       : $topicStatus =~ m/D[\ M]/  ? 'deleted from index' 
    201       : $topicStatus =~ m/R[\ MD]/ ? 'renamed in index' 
    202       : $topicStatus =~ m/C[\ MD]/ ? 'copied in index' 
    203       : $topicStatus eq '' ? 'up to date' 
    204       :                      'unknown'; 
    205  
    206     ( my $topicinfo, $exit ) = 
    207       Foswiki::Sandbox->sysCommand( "$gitbin $repoLoc log -1  $absfile ", ); 
    208  
    209     my $report = "*Repo file:* =$absfile= \n\n*Repo root:* $repoRoot\n\n"; 
    210  
    211     $report .= "*File Status:* ($topicStatus) - $status\n\n"; 
    212  
    213     $report .= "*Last Commit:* \n" . '<verbatim>' . $topicinfo . '</verbatim>' 
    214       unless $exit; 
    215  
    216     return $report; 
    217  
     187    elsif ( $default eq 'status' ) { 
     188        #my ($curdir) = getcwd =~ m/^(.*)$/; 
     189        #chdir($repoRoot); 
     190        ( my $repoInfo, $exit ) = 
     191          Foswiki::Sandbox->sysCommand( "$gitbin $repoLoc status -uno", ); 
     192        #chdir($curdir); 
     193        my $report .= " " . '<verbatim>' . $repoInfo . '</verbatim>' 
     194          unless $exit; 
     195 
     196        return $report; 
     197    } 
     198    else { 
     199 
     200        ( my $fileStatus, $exit ) = Foswiki::Sandbox->sysCommand( 
     201            "$gitbin $repoLoc status --porcelain  $absfile ", 
     202        ); 
     203 
     204        $fileStatus = substr( $fileStatus, 0, 2 ); 
     205 
     206        return "*File not known to git:* =$absfile= " if ( $fileStatus eq '??' ); 
     207 
     208        my $status = 
     209            $fileStatus =~ m/\ [MD]/  ? 'Modified, not updated in index' 
     210          : $fileStatus =~ m/M[\ MD]/ ? 'updated in index' 
     211          : $fileStatus =~ m/A[\ MD]/ ? 'added to index' 
     212          : $fileStatus =~ m/D[\ M]/  ? 'deleted from index' 
     213          : $fileStatus =~ m/R[\ MD]/ ? 'renamed in index' 
     214          : $fileStatus =~ m/C[\ MD]/ ? 'copied in index' 
     215          : $fileStatus eq '' ? 'up to date' 
     216          :                      'unknown'; 
     217 
     218        ( my $topicinfo, $exit ) = 
     219          Foswiki::Sandbox->sysCommand( "$gitbin $repoLoc log -1  $absfile ", ); 
     220 
     221        my $report = "*Repo file:* =$absfile= \n\n*Repo root:* $repoRoot\n\n"; 
     222 
     223        $report .= "*File Status:* ($fileStatus) - $status\n\n"; 
     224 
     225        $report .= "*Last Commit:* \n" . '<verbatim>' . $topicinfo . '</verbatim>' 
     226          unless $exit; 
     227 
     228        return $report; 
     229    } 
     230 
     231 
     232### 
     233### DEAD CODE  
     234### 
    218235    my ( $gitinfo, $gexit ) = 
    219236      Foswiki::Sandbox->sysCommand( "$gitbin $repoLoc svn info ", ); 
     
    227244      unless ( $sexit || $svninfo =~ m/not a working copy/ ); 
    228245 
    229  #    if ($repoInfo->{type} eq 'svn') { 
    230  #        $svninfo =~ /Path: ( 
    231  #    Path: . 
    232  #    URL: http://svn.twiki.org/svn/twiki/trunk/core 
    233  #    Repository Root: http://svn.twiki.org/svn 
    234  #    Repository UUID: a00a5322-12db-0310-a70b-8735589c885e 
    235  #    Revision: 19150 
    236  #    Node Kind: directory 
    237  #    Schedule: normal 
    238  #    Last Changed Author: PeterThoeny 
    239  #    Last Changed Rev: 19140 
    240  #    Last Changed Date: 2010-06-27 02:42:03 -0400 (Sun, 27 Jun 2010) 
    241  # 
    242  #    gac@cardinal: /data/gac/SVN/twiki/core $ cd - 
    243  #    /data/gac/SVN/twiki 
    244  #    gac@cardinal: /data/gac/SVN/twiki $ cd /var/www/foswiki/trunk/ 
    245  #    gac@cardinal: /var/www/foswiki/trunk (Item9238-BuildContrib)$ git svn info 
    246  #    Path: . 
    247  #    URL: http://svn.foswiki.org/trunk 
    248  #    Repository Root: http://svn.foswiki.org 
    249  #    Repository UUID: 0b4bb1d4-4e5a-0410-9cc4-b2b747904278 
    250  #    Revision: 8030 
    251  #    Node Kind: directory 
    252  #    Schedule: normal 
    253  #    Last Changed Author: CrawfordCurrie 
    254  #    Last Changed Rev: 8030 
    255  #    Last Changed Date: 2010-07-05 05:21:49 -0400 (Mon, 05 Jul 2010) 
    256  # 
    257246 
    258247    my $cmd = $params->{_DEFAULT} || ''; 
Note: See TracChangeset for help on using the changeset viewer.