| 1 | # Copyright (C) 2009 Wes Hardaker | ||
| 2 | # License: GNU GPLv2. See the COPYING file for details. | ||
| 3 | package TheOneRing::GIT; | ||
| 4 | |||
| 5 | use strict; | ||
| 6 | use TheOneRing; | ||
| 7 | |||
| 8 | our @ISA = qw(TheOneRing); | ||
| 9 | |||
| 10 | our $VERSION = '0.3'; | ||
| 11 | |||
| 12 | sub init { | ||
| 13 | my ($self) = @_; | ||
| 14 | $self->{'command'} = 'git'; | ||
| 15 | $self->{'mapping'} = | ||
| 16 | { | ||
| 17 | 'status' => | ||
| 18 | { | ||
| 19 | 'args' => { }, | ||
| 20 | }, | ||
| 21 | |||
| 22 | # XXX: commit -a for commiting all files | ||
| 23 | 'commit' => | ||
| 24 | { | ||
| 25 | options => sub { my ($self, @args) = @_; | ||
| 26 | return ['-a'] if ($#args == -1); | ||
| 27 | return [] }, | ||
| 28 | 'args' => { m => '-m' }, | ||
| 29 | }, | ||
| 30 | |||
| 31 | 'update' => | ||
| 32 | { | ||
| 33 | 'command' => 'pull', | ||
| 34 | 'options' => ['origin', 'HEAD'], | ||
| 35 | 'args' => { | ||
| 36 | # r => '-r', | ||
| 37 | # q => 'q', | ||
| 38 | # N => 'N', | ||
| 39 | }, | ||
| 40 | }, | ||
| 41 | |||
| 42 | # need a special function for this to deal with how revs are handled | ||
| 43 | # ie, -r foo file => foo file | ||
| 44 | 'diff' => | ||
| 45 | { | ||
| 46 | 'args' => { }, | ||
| 47 | }, | ||
| 48 | |||
| 49 | 'annotate' => | ||
| 50 | { | ||
| 51 | args => { } | ||
| 52 | }, | ||
| 53 | |||
| 54 | # 'info' => | ||
| 55 | # { | ||
| 56 | # args => { r => '-r' } | ||
| 57 | # }, | ||
| 58 | |||
| 59 | 'add' => | ||
| 60 | { | ||
| 61 | args => { #N => 'N', | ||
| 62 | #q => 'q' | ||
| 63 | } | ||
| 64 | }, | ||
| 65 | |||
| 66 | 'remove' => | ||
| 67 | { | ||
| 68 | command => 'rm', | ||
| 69 | args => { #N => 'N', | ||
| 70 | q => 'q' | ||
| 71 | } | ||
| 72 | }, | ||
| 73 | |||
| 74 | # 'list' => | ||
| 75 | # { | ||
| 76 | # args => { N => 'N', | ||
| 77 | # q => 'q', | ||
| 78 | # r => '-r'} | ||
| 79 | # }, | ||
| 80 | |||
| 81 | # 'export' => | ||
| 82 | # { | ||
| 83 | # args => { N => 'N', | ||
| 84 | # q => 'q', | ||
| 85 | # r => '-r'} | ||
| 86 | # }, | ||
| 87 | |||
| 88 | 'log' => | ||
| 89 | { | ||
| 90 | args => { #q => 'q', | ||
| 91 | #r => '-r' | ||
| 92 | } | ||
| 93 | }, | ||
| 94 | |||
| 95 | 'revert' => | ||
| 96 | { | ||
| 97 | # XXX: requires file names to revert | ||
| 98 | command => 'checkout', | ||
| 99 | args => { # q => 'q', | ||
| 100 | # N | ||
| 101 | }, | ||
| 102 | }, | ||
| 103 | |||
| 104 | }; | ||
| 105 | } | ||
| 106 | |||
| 107 | sub ignore { | ||
| 108 | my ($self, @args) = @_; | ||
| 109 | $self->add_to_file(".gitignore", @args); | ||
| 110 | } | ||
| 111 | |||
| 112 | sub move { | ||
| 113 | my ($self, @args) = @_; | ||
| 114 | $self->move_by_adddel(@args); | ||
| 115 | } | ||
| 116 | |||
| 117 | 1; |