Class: Gitgit::CLI
Overview
Your code goes hereā¦
Instance Method Summary collapse
- #init ⇒ Object
- #lg ⇒ Object
- #publish ⇒ Object
- #push ⇒ Object
- #save ⇒ Object
- #status ⇒ Object
- #version ⇒ Object
Instance Method Details
#init ⇒ Object
11 12 13 14 15 |
# File 'lib/gitgit.rb', line 11 def init return unless yes? "You're in the folder #{Dir.pwd}. Are you sure you want to make it into a git repository? (y/n)" Git.init say "Git repo created! Let's git going ...", :green end |
#lg ⇒ Object
43 44 45 46 |
# File 'lib/gitgit.rb', line 43 def lg g = Git.open('.') g.log(20).each {|l| puts l } end |
#publish ⇒ Object
67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/gitgit.rb', line 67 def publish g = get_git_repo || return if g.remotes.empty? say "Can't push as this repository has no remotes!", :red say "" say "You need to set up a repository on github and follow the instructions to connect it to this folder on your laptop." return end g.push(g.remote('origin'), 'master:gh-pages', force: true) say "Site pushed to the gh-pages branch on github!", :green end |
#push ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/gitgit.rb', line 49 def push g = get_git_repo || return if g.remotes.empty? say "Can't push as this repository has no remotes!", :red say "" say "You need to set up a repository on github and follow the instructions to connect it to this folder on your laptop." return end g.push say "Work successfully pushed to github!", :green rescue Git::GitExecuteError say "There was a problem pushing your work to github. :(", :red end |
#save ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/gitgit.rb', line 18 def save g = get_git_repo || return say "You're about to save the following changes:" say "" show_status(g) return unless yes? "Do you want to save these changes to git? (y/n)" m = ask "Give a short description of the work you're saving: " g.add(all:true) g.commit(m) say "Changes saved! :)", :green end |
#status ⇒ Object
33 34 35 36 37 38 39 40 |
# File 'lib/gitgit.rb', line 33 def status g = get_git_repo || return say "The following changes have occurred since your last save:" show_status(g) say "" say "Type 'gitgit save' to save your work!" say "" end |