Class: Releasinator::GitUtil
- Inherits:
-
Object
- Object
- Releasinator::GitUtil
- Defined in:
- lib/git_util.rb
Class Method Summary collapse
- .cached ⇒ Object
- .checkout(branch_name) ⇒ Object
- .delete_branch(branch_name) ⇒ Object
- .diff ⇒ Object
- .get_current_branch ⇒ Object
- .has_branch?(branch_name) ⇒ Boolean
- .has_remote_branch?(branch_name) ⇒ Boolean
- .init_gh_pages ⇒ Object
- .is_clean_git? ⇒ Boolean
- .repo_url ⇒ Object
- .untracked_files ⇒ Object
Class Method Details
.cached ⇒ Object
22 23 24 |
# File 'lib/git_util.rb', line 22 def self.cached CommandProcessor.command("git diff --cached") end |
.checkout(branch_name) ⇒ Object
44 45 46 47 48 |
# File 'lib/git_util.rb', line 44 def self.checkout(branch_name) if get_current_branch != branch_name CommandProcessor.command("git checkout #{branch_name}") end end |
.delete_branch(branch_name) ⇒ Object
30 31 32 33 34 |
# File 'lib/git_util.rb', line 30 def self.delete_branch(branch_name) if has_branch? branch_name CommandProcessor.command("git branch -D #{branch_name}") end end |
.diff ⇒ Object
18 19 20 |
# File 'lib/git_util.rb', line 18 def self.diff CommandProcessor.command("git diff") end |
.get_current_branch ⇒ Object
10 11 12 |
# File 'lib/git_util.rb', line 10 def self.get_current_branch CommandProcessor.command("git symbolic-ref --short HEAD").strip end |
.has_branch?(branch_name) ⇒ Boolean
36 37 38 |
# File 'lib/git_util.rb', line 36 def self.has_branch?(branch_name) "" != CommandProcessor.command("git branch --list #{branch_name}").strip end |
.has_remote_branch?(branch_name) ⇒ Boolean
40 41 42 |
# File 'lib/git_util.rb', line 40 def self.has_remote_branch?(branch_name) "" != CommandProcessor.command("git branch --list -r #{branch_name}").strip end |
.init_gh_pages ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/git_util.rb', line 50 def self.init_gh_pages if !has_branch? "gh-pages" if has_remote_branch? "origin/gh-pages" checkout("gh-pages") else CommandProcessor.command("git checkout --orphan gh-pages") CommandProcessor.command("GLOBIGNORE='.git' git rm -rf *") #http://stackoverflow.com/questions/19363795/git-rm-doesnt-remove-all-files-in-one-go CommandProcessor.command("GLOBIGNORE='.git' git rm -rf *") CommandProcessor.command("touch README.md") CommandProcessor.command("git add .") CommandProcessor.command("git commit -am \"Initial gh-pages commit\"") CommandProcessor.command("git push -u origin gh-pages") end end end |
.is_clean_git? ⇒ Boolean
5 6 7 8 |
# File 'lib/git_util.rb', line 5 def self.is_clean_git? any_changes = CommandProcessor.command("git status --porcelain") '' == any_changes end |
.repo_url ⇒ Object
26 27 28 |
# File 'lib/git_util.rb', line 26 def self.repo_url CommandProcessor.command("git config --get remote.origin.url").strip end |
.untracked_files ⇒ Object
14 15 16 |
# File 'lib/git_util.rb', line 14 def self.untracked_files CommandProcessor.command("git ls-files --others --exclude-standard") end |