Module: Brigit

Defined in:
lib/brigit/version.rb,
lib/brigit.rb,
lib/brigit/cli.rb,
lib/brigit/fallible.rb,
lib/brigit/listable.rb,
lib/brigit/pretending.rb,
lib/brigit/config_parser.rb,
lib/brigit/commands/command.rb,
lib/brigit/commands/hop_command.rb,
lib/brigit/commands/map_command.rb,
lib/brigit/commands/grab_command.rb,
lib/brigit/inventories/inventory.rb,
lib/brigit/commands/status_command.rb,
lib/brigit/commands/update_command.rb,
lib/brigit/inventories/gitosis_inventory.rb

Overview

(The MIT License)

Copyright © 2008 Jamis Buck <[email protected]>,

with modifications by Bruce Williams <[email protected]>

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the ‘Software’), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED ‘AS IS’, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Defined Under Namespace

Modules: Fallible, Listable, Pretending Classes: CLI, Command, ConfigParser, GitosisInventory, GrabCommand, HopCommand, Inventory, MapCommand, StatusCommand, UpdateCommand, Version

Class Method Summary collapse

Class Method Details

.at_dot_gitmodules(base = Dir.pwd) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
# File 'lib/brigit.rb', line 12

def self.at_dot_gitmodules(base = Dir.pwd)
  Find.find(base) do |path|
    if File.basename(path) == '.git' && File.directory?(path)
      Find.prune
    elsif File.file?(File.join(path, '.gitmodules'))
      Dir.chdir path do
        yield path
      end
    end
  end
end

.at_repos(submodules = false, base = Dir.pwd) ⇒ Object



42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/brigit.rb', line 42

def self.at_repos(submodules = false, base = Dir.pwd)
  Find.find(base) do |path|
    if File.basename(path) == '.git' && File.directory?(path)
      Find.prune
    elsif File.directory?(File.join(path, '.git'))
      Dir.chdir path do
        yield path
      end
      Find.prune unless submodules
    end
  end
end

.parent_of(path) ⇒ Object

Note: Doesn’t validate against .gitmodules or .git/config



25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/brigit.rb', line 25

def self.parent_of(path)
  components = path.split(File::SEPARATOR)
  components.pop
  matched = []
  components.inject(['']) do |list, component|
    list << component
    check_path = File.join(*list.clone.push('.git'))
    matched << File.dirname(check_path) if File.exists?(check_path)
    list
  end
  matched.pop
end

.repoObject



55
56
57
# File 'lib/brigit.rb', line 55

def self.repo
  Git.open(Dir.pwd)
end

.submodule?(path) ⇒ Boolean

Returns:

  • (Boolean)


38
39
40
# File 'lib/brigit.rb', line 38

def self.submodule?(path)
  parent_of(path)
end