Module: Homebrew::GitRepository

Defined in:
app/models/homebrew/git_repository.rb

Overview

Homebrew Git repository interface

Author:

  • guillaumeh

Class Method Summary collapse

Class Method Details

.clone_git_repositoryObject


40
41
42
43
44
45
46
47
# File 'app/models/homebrew/git_repository.rb', line 40

def self.clone_git_repository
  Git.clone(
    AppConfig.homebrew.git_repository.url,
    AppConfig.homebrew.git_repository.name,
    path: AppConfig.homebrew.git_repository.location,
    depth: 1 # Without the history
  )
end

.fetch_up_to_date_git_repositoryObject

Get the Homebrew formulas from Github.com

In the case of the source code folder is missing this method will clone the repository (without the history) otherwise just call `git pull`.


15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'app/models/homebrew/git_repository.rb', line 15

def self.fetch_up_to_date_git_repository
  git = if File.exist?(AppConfig.homebrew.git_repository.location)
          open_git_repository
        else
          path = File.join(AppConfig.homebrew.git_repository.location,
                           AppConfig.homebrew.git_repository.name)
          # Create the location path
          FileUtils.mkdir_p(path)
          # Clone the Git repo to the location path
          clone_git_repository
        end

  # Update the code to the HEAD version
  git.pull
end

.open_git_repositoryObject


31
32
33
34
35
36
37
38
# File 'app/models/homebrew/git_repository.rb', line 31

def self.open_git_repository
  Git.open(
    File.join(
      AppConfig.homebrew.git_repository.location,
      AppConfig.homebrew.git_repository.name
    )
  )
end