public
Description: Piston is a utility that eases vendor branch management. This repository is a complete reimplementation of Piston to provide different backends, depending on the repositories and working copies you pistonize from.
Homepage: http://piston.rubyforge.org/
Clone URL: git://github.com/francois/piston.git
francois (author)
Sun Mar 16 19:43:20 -0700 2008
commit  0b96e22dc0b68781ea443ae39afab6c246dd1b47
tree    19e3468e9ae95e254b9bd6e36c0872c66ec8e3ec
parent  9b7391c8f907342387fff51aef4f020f1065ae85
piston / lib / piston / git / working_copy.rb
100644 48 lines (39 sloc) 0.967 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
require "piston/working_copy"
require "piston/git/client"
 
module Piston
  module Git
    class WorkingCopy < Piston::WorkingCopy
      extend Piston::Git::Client
      def git(*args); self.class.git(*args); end
 
      # Register ourselves as a handler for working copies
      Piston::WorkingCopy.add_handler self
 
      class << self
        def understands_dir?(dir)
          path = dir
          begin
            while path.parent
              response = git(:status, path)
              return true if response =~ /# On branch /
              path = path.parent
            end
          rescue BadCommand
            # NOP, as we return false below
          end
 
          false
        end
      end
 
      def create
        path.mkpath rescue nil
      end
 
      def exist?
        path.directory?
      end
 
      def finalize
        git(:add, path)
      end
 
      def finalize
        Dir.chdir(path) { git(:add, ".") }
      end
    end
  end
end