Class: Capistrano::Campout::GitUtils
- Inherits:
-
Object
- Object
- Capistrano::Campout::GitUtils
- Defined in:
- lib/capistrano-campout/git_utils.rb
Instance Method Summary collapse
- #github_compare_url(previous_revision, latest_revision) ⇒ Object
- #github_url_for_repository ⇒ Object
-
#initialize(path) ⇒ GitUtils
constructor
A new instance of GitUtils.
- #localrepo ⇒ Object
- #repository=(repository) ⇒ Object
- #repository_is_github? ⇒ Boolean
- #user_name ⇒ Object
Constructor Details
#initialize(path) ⇒ GitUtils
Returns a new instance of GitUtils.
13 14 15 16 17 18 19 20 |
# File 'lib/capistrano-campout/git_utils.rb', line 13 def initialize(path) @path = path if(localrepo) return self else return nil end end |
Instance Method Details
#github_compare_url(previous_revision, latest_revision) ⇒ Object
61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/capistrano-campout/git_utils.rb', line 61 def github_compare_url(previous_revision, latest_revision) if(repository_is_github?) if(previous_revision != latest_revision) "#{github_url_for_repository}/compare/#{previous_revision}...#{latest_revision}" else "#{github_url_for_repository}/commit/#{latest_revision}" end else nil end end |
#github_url_for_repository ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/capistrano-campout/git_utils.rb', line 45 def github_url_for_repository if(!@mogrified_repository) if(@repository =~ /[email protected]/) @mogrified_repository = @repository.dup @mogrified_repository.gsub!(/git@/, 'http://') @mogrified_repository.gsub!(/\.com:/,'.com/') @mogrified_repository.gsub!(/\.git/, '') end end @mogrified_repository end |
#localrepo ⇒ Object
22 23 24 25 26 27 28 29 30 |
# File 'lib/capistrano-campout/git_utils.rb', line 22 def localrepo if(@localrepo.nil?) begin @localrepo = Grit::Repo.new(@path) rescue Grit::InvalidGitRepositoryError end end @localrepo end |
#repository=(repository) ⇒ Object
41 42 43 |
# File 'lib/capistrano-campout/git_utils.rb', line 41 def repository=(repository) @repository = repository end |
#repository_is_github? ⇒ Boolean
57 58 59 |
# File 'lib/capistrano-campout/git_utils.rb', line 57 def repository_is_github? return (!github_url_for_repository.nil?) end |
#user_name ⇒ Object
32 33 34 35 36 37 38 39 |
# File 'lib/capistrano-campout/git_utils.rb', line 32 def user_name if(localrepo) git_config = Grit::Config.new(localrepo) git_config.fetch('user.name') else nil end end |