Class: Sleet::LocalRepo

Inherits:
Object
  • Object
show all
Defined in:
lib/sleet/local_repo.rb

Constant Summary collapse

REMOTE_BRANCH_REGEX =
%r{^([^\/.]+)\/(.+)}.freeze
CURRENT_BRANCH_REGEX =
%r{^refs\/heads\/}.freeze
GITHUB_MATCH_REGEX =
%r{github.com[:\/](.+)\/(.+)\.git}.freeze

Instance Method Summary collapse

Constructor Details

#initialize(source_dir:) ⇒ LocalRepo

Returns a new instance of LocalRepo.



9
10
11
# File 'lib/sleet/local_repo.rb', line 9

def initialize(source_dir:)
  @source_dir = source_dir
end

Instance Method Details

#branch_nameObject



25
26
27
28
29
# File 'lib/sleet/local_repo.rb', line 25

def branch_name
  validate!

  current_branch.upstream.name.match(REMOTE_BRANCH_REGEX)[2]
end

#projectObject



19
20
21
22
23
# File 'lib/sleet/local_repo.rb', line 19

def project
  validate!

  github_match[2]
end

#usernameObject



13
14
15
16
17
# File 'lib/sleet/local_repo.rb', line 13

def username
  validate!

  github_match[1]
end