Browse Source

Added "real" get_current_revision

Alois Mahdal 11 years ago
parent
commit
0f16975840

+ 1
- 0
lib/SugarTrail/Repo.pm View File

28
     $master->{text} = $self->load_text($args->{source})
28
     $master->{text} = $self->load_text($args->{source})
29
         or return;
29
         or return;
30
     $master->{source} = $args->{source};
30
     $master->{source} = $args->{source};
31
+    $master->{revision} = $self->get_revision($args->{source});
31
 
32
 
32
     return $master;
33
     return $master;
33
 }
34
 }

+ 7
- 0
lib/SugarTrail/Repo/Filesystem.pm View File

30
     return $self->{root} . $source;
30
     return $self->{root} . $source;
31
 }
31
 }
32
 
32
 
33
+sub get_revision {
34
+    my $self = shift;
35
+    my $source = shift // $self->{source};
36
+    my $file = $self->_get_filename($source);
37
+    return (stat($file))[9];  # 9 = mtime
38
+}
39
+
33
 sub load_text {
40
 sub load_text {
34
     my $self = shift;
41
     my $self = shift;
35
     my $source = shift;
42
     my $source = shift;

+ 1
- 6
lib/SugarTrail/Template/Master.pm View File

99
     }
99
     }
100
 
100
 
101
     $slave->{meta}->{'Master'} = $self->{source};
101
     $slave->{meta}->{'Master'} = $self->{source};
102
-    $slave->{meta}->{'Master Revision'} = $self->get_current_revision();
102
+    $slave->{meta}->{'Master Revision'} = $self->{revision};
103
     $slave->{meta}->{'Params'} = mkmymime($args);
103
     $slave->{meta}->{'Params'} = mkmymime($args);
104
 
104
 
105
     $slave->{steps} = \@slave_steps;
105
     $slave->{steps} = \@slave_steps;
106
     return $slave;
106
     return $slave;
107
 }
107
 }
108
 
108
 
109
-# skel: returns time (might be useful in absence of VCS)
110
-sub get_current_revision {
111
-    return time;
112
-}
113
-
114
 sub mkmymime {
109
 sub mkmymime {
115
     my $d = shift;
110
     my $d = shift;
116
     my $d1 = "; "; my $d2 = "=";
111
     my $d1 = "; "; my $d2 = "=";