| File: | lib/App/TimeTracker/Command/SyncViaGit.pm |
| Coverage: | 70.0% |
| line | stmt | bran | cond | sub | pod | time | code |
|---|---|---|---|---|---|---|---|
| 1 | package App::TimeTracker::Command::SyncViaGit; | ||||||
| 2 | 2 2 2 | 1308 4 39 | use strict; | ||||
| 3 | 2 2 2 | 9 4 48 | use warnings; | ||||
| 4 | 2 2 2 2 2 2 | 65 90 26 11 5 23 | use 5.010; | ||||
| 5 | |||||||
| 6 | # ABSTRACT: TimeTracker SyncViaGit plugin | ||||||
| 7 | |||||||
| 8 | 2 2 2 | 9 5 19 | use Moose::Role; | ||||
| 9 | 2 2 2 | 6188 6 19 | use Git::Repository; | ||||
| 10 | |||||||
| 11 | sub cmd_sync { | ||||||
| 12 | 0 | 0 | my $self = shift; | ||||
| 13 | |||||||
| 14 | 0 | my $r = Git::Repository->new( work_tree => $self->home ); | |||||
| 15 | |||||||
| 16 | 0 | my @new = $r->run('ls-files' =>'-om'); | |||||
| 17 | 0 | foreach my $changed (@new) { | |||||
| 18 | 0 | $r->run(add=>$changed); | |||||
| 19 | } | ||||||
| 20 | |||||||
| 21 | 0 | $r->run(commit => '-m','synced on '.$self->now); | |||||
| 22 | |||||||
| 23 | 0 | foreach my $cmd (qw(pull push)) { | |||||
| 24 | 0 | my $c = $r->command( $cmd ); | |||||
| 25 | 0 | print $c->stderr->getlines; | |||||
| 26 | 0 | $c->close; | |||||
| 27 | } | ||||||
| 28 | } | ||||||
| 29 | |||||||
| 30 | 2 2 2 | 281 5 15 | no Moose::Role; | ||||
| 31 | 1; | ||||||
| 32 | |||||||