Module: Git
- Defined in:
- lib/git.rb
Constant Summary collapse
- @@wagon =
"wagon-branch"
- @@local =
"local-branch"
Class Method Summary collapse
-
.add_all ⇒ Object
Add all local changes to be committed.
- .checkout(branch) ⇒ Object
- .checkout_master ⇒ Object
- .checkout_new_local ⇒ Object
- .checkout_new_wagon ⇒ Object
- .clean_whitespace_changes ⇒ Object
-
.commit(message) ⇒ Object
Git commit using provided message.
-
.commit_prompt ⇒ Object
Git commit, will prompt user for commit message.
- .delete_branch(branch) ⇒ Object
- .delete_local ⇒ Object
- .delete_wagon ⇒ Object
- .has_changes? ⇒ Boolean
-
.is_git_dir?(dir = Dir.pwd) ⇒ Boolean
Return true if the provided directory is in a git repo, otherwise false.
- .merge(branch) ⇒ Object
- .merge_local ⇒ Object
- .merge_wagon ⇒ Object
-
.pull ⇒ Object
Git pull.
-
.push ⇒ Object
Git push.
- .rebase(from, to) ⇒ Object
- .rebase_local ⇒ Object
- .rebase_wagon ⇒ Object
- .stash ⇒ Object
- .stash_pop ⇒ Object
Class Method Details
.add_all ⇒ Object
Add all local changes to be committed.
9 10 11 |
# File 'lib/git.rb', line 9 def self.add_all() Command.run("git add -A .") end |
.checkout(branch) ⇒ Object
39 40 41 |
# File 'lib/git.rb', line 39 def self.checkout(branch) Command.run("git checkout #{branch}") end |
.checkout_master ⇒ Object
43 44 45 |
# File 'lib/git.rb', line 43 def self.checkout_master() self.checkout("master") end |
.checkout_new_local ⇒ Object
51 52 53 |
# File 'lib/git.rb', line 51 def self.checkout_new_local() self.checkout("-b #{@@local}") end |
.checkout_new_wagon ⇒ Object
47 48 49 |
# File 'lib/git.rb', line 47 def self.checkout_new_wagon() self.checkout("-b #{@@wagon}") end |
.clean_whitespace_changes ⇒ Object
103 104 105 106 |
# File 'lib/git.rb', line 103 def self.clean_whitespace_changes() # git stash && git stash apply && git diff -w > ws.patch && git checkout . && git apply --ignore-space-change --ignore-whitespace ws.patch && rm ws.patch puts "This does nothin yet" end |
.commit(message) ⇒ Object
Git commit using provided message
23 24 25 |
# File 'lib/git.rb', line 23 def self.commit() Command.run("git commit -m '#{}'") end |
.commit_prompt ⇒ Object
Git commit, will prompt user for commit message
15 16 17 18 19 20 |
# File 'lib/git.rb', line 15 def self.commit_prompt() return unless has_changes? puts "Enter a git commit message:" = $stdin.gets.chomp self.commit() end |
.delete_branch(branch) ⇒ Object
55 56 57 |
# File 'lib/git.rb', line 55 def self.delete_branch(branch) Command.run("git branch -D #{branch}") end |
.delete_local ⇒ Object
63 64 65 |
# File 'lib/git.rb', line 63 def self.delete_local() self.delete_branch(@@local) end |
.delete_wagon ⇒ Object
59 60 61 |
# File 'lib/git.rb', line 59 def self.delete_wagon() self.delete_branch(@@wagon) end |
.has_changes? ⇒ Boolean
99 100 101 |
# File 'lib/git.rb', line 99 def self.has_changes?() return !!Command.run("git ls-files -m") end |
.is_git_dir?(dir = Dir.pwd) ⇒ Boolean
Return true if the provided directory is in a git repo, otherwise false. Can optionally provide wa
110 111 112 113 114 |
# File 'lib/git.rb', line 110 def self.is_git_dir?(dir = Dir.pwd) return Dir.chdir dir do return Command.run("git rev-parse", false) end end |
.merge(branch) ⇒ Object
75 76 77 |
# File 'lib/git.rb', line 75 def self.merge(branch) Command.run("git merge #{branch}") end |
.merge_local ⇒ Object
83 84 85 |
# File 'lib/git.rb', line 83 def self.merge_local() self.merge(@@local) end |
.merge_wagon ⇒ Object
79 80 81 |
# File 'lib/git.rb', line 79 def self.merge_wagon() self.merge(@@wagon) end |
.pull ⇒ Object
Git pull
35 36 37 |
# File 'lib/git.rb', line 35 def self.pull() Command.run("git pull") end |
.push ⇒ Object
Git push
29 30 31 |
# File 'lib/git.rb', line 29 def self.push() Command.run("git push") end |
.rebase(from, to) ⇒ Object
87 88 89 |
# File 'lib/git.rb', line 87 def self.rebase(from, to) Command.run("git rebase #{} #{}") end |
.rebase_local ⇒ Object
95 96 97 |
# File 'lib/git.rb', line 95 def self.rebase_local() self.rebase("master", @@local) end |
.rebase_wagon ⇒ Object
91 92 93 |
# File 'lib/git.rb', line 91 def self.rebase_wagon() self.rebase("master", @@wagon) end |