Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Git on WebApp with Perl

Git on WebApp with Perl

Git リポジトリを表示したり操作したりするアプリケーションをPerlで作成する方法について開設します。

hakobe (Yohei Fushii)

March 17, 2012
Tweet

More Decks by hakobe (Yohei Fushii)

Other Decks in Programming

Transcript

  1. HJU

  2. 1FSM͔Βͷ(JU ❖Git.pm  HJUʹ෇ଐͯ͠Δ  $1"/Ϟδϡʔϧ͡Όͳ͍ ❖Git::Class/Git::Wrapper  JOUFSBDUJWFͳίϚϯυ͕࢖͑ͳ͍ ❖Git::Repository

     "1*͕γϯϓϧͰׂΓ੾ͬͯΔ  JOUFSBDUJWFͳίϚϯυ͕࢖͑Δ TFFIUUQTFBSDIDQBOPSHdCPPL(JU3FQPTJUPSZMJC(JU 3FQPTJUPSZQN05)&3@1&3-@(*5@83"11&34
  3. (JU3FQPTJUPSZ 1 use Git::Repository; 2 3 # ϦϙδτϦͷࢦఆ 4 my

    $git; 5 $git = Git::Repository->new( 6 git_dif => '/path/to/.git' ); 7 $git = Git::Repository->new( 8 work_tree => '/path/to/working_copy' ); 9 18
  4. (JU3FQPTJUPSZ 10 # ίϚϯυͷ࣮ߦ 11 my $status = $git->run('status'); 12

    my @diff = $git->run('diff', 'HEAD^...HEAD'); 13 14 # ίϚϯυͷ࣮ߦ࣌ʹೖग़ྗΛ੍ޚ 15 my $cmd = $git->command('add', '-p', '-u'); 16 $cmd->stdout; 17 $cmd->stdin; 18
  5. CSBODIS 1 use Git::Repository; 2 3 my $git; 4 $git

    = Git::Repository->new( 5 git_dif => '/path/to/.git' ); 6 7 my @branches = 8 map { $_ =~ s/\s+//g; $_ } 9 $self->git->run('branch', '-r'); 10 origin/fix_bug origin/workerenchance origin/xpath_entryimage
  6. EJ⒎ ύʔε͸ུ 1 diff --git a/lib/Guita/Mapper/Git.pm b/lib/Guita/Mapper/Git.pm 2 index 9ee4a36..5dd6ed5

    100644 3 --- a/lib/Guita/Mapper/Git.pm 4 +++ b/lib/Guita/Mapper/Git.pm 5 @@ -226,4 +226,9 @@ sub ls_tree { 6 return $results; 7 } 8 9 +sub config { 10 + my $self = shift; 11 + $self->git->run('config', @_); 12 +} 13 + 14 1; 15 diff --git a/lib/Guita/Pick.pm b/lib/Guita/Pick.pm 16 index 4c37820..29f75cb 100644 17 --- a/lib/Guita/Pick.pm 18 +++ b/lib/Guita/Pick.pm 19 @@ -37,10 +37,14 @@ sub create { 20 Guita::Git->run(init => $work_tree->stringify);
  7. (VJUB ⿣ HJTUDMPOF  ࣾ಺޲͚HJTU΄͍͠͠࡞ͬͨ  ̋1FSMͰॻ͔ΕͯΔ  ✕MJCHJU࢖ͬͯͳ͍ 

    ࢖͍͍ͨͻͱ͓͓͔ͬͨΒؤுΓ͍ͨ  σϞ IUUQTHJUIVCDPNIBLPCF(VJUB