Class: GithubPages::GitManager
- Inherits:
-
Object
- Object
- GithubPages::GitManager
- Defined in:
- lib/ghpages_deploy/git_manager.rb
Class Method Summary collapse
Instance Method Summary collapse
- #cleanup ⇒ Object
- #commit_and_push(msg) ⇒ Object
-
#initialize(remote, preserved_dir) ⇒ GitManager
constructor
A new instance of GitManager.
- #ls_files(dir) ⇒ Object
- #remove(*files) ⇒ Object
- #stage(files) ⇒ Object
- #staged_modifications(dir) ⇒ Object
Constructor Details
#initialize(remote, preserved_dir) ⇒ GitManager
Returns a new instance of GitManager.
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/ghpages_deploy/git_manager.rb', line 9 def initialize(remote, preserved_dir) @preserved = preserved_dir @remote = remote @repo = `git config remote.#{remote}.url`.gsub(/^git:/, 'https:') @branch = if @repo =~ /\.github\.(?:com|io)\.git$/ 'master' else 'gh-pages' end @git = Git.open(Dir.pwd) setup end |
Class Method Details
.open(*args) {|git| ... } ⇒ Object
25 26 27 28 29 |
# File 'lib/ghpages_deploy/git_manager.rb', line 25 def self.open(*args, &block) git = new(*args, &block) yield git git.cleanup end |
Instance Method Details
#cleanup ⇒ Object
31 32 33 |
# File 'lib/ghpages_deploy/git_manager.rb', line 31 def cleanup cleanup_credentials end |
#commit_and_push(msg) ⇒ Object
47 48 49 50 |
# File 'lib/ghpages_deploy/git_manager.rb', line 47 def commit_and_push(msg) @git.commit(msg) @git.push(remote, branch) end |
#ls_files(dir) ⇒ Object
43 44 45 |
# File 'lib/ghpages_deploy/git_manager.rb', line 43 def ls_files(dir) cached_files('ls-files', dir) end |
#remove(*files) ⇒ Object
52 53 54 |
# File 'lib/ghpages_deploy/git_manager.rb', line 52 def remove(*files) @git.remove(files) unless files.empty? end |
#stage(files) ⇒ Object
35 36 37 |
# File 'lib/ghpages_deploy/git_manager.rb', line 35 def stage(files) @git.add files unless files.empty? end |
#staged_modifications(dir) ⇒ Object
39 40 41 |
# File 'lib/ghpages_deploy/git_manager.rb', line 39 def staged_modifications(dir) cached_files('diff --name-only', dir) end |