Class: Raykit::Git
- Inherits:
-
Object
- Object
- Raykit::Git
- Defined in:
- lib/raykit/git.rb
Instance Attribute Summary collapse
-
#start_time ⇒ Object
Returns the value of attribute start_time.
Class Method Summary collapse
- .add_remote ⇒ Object
- .branch ⇒ Object
- .get_remote ⇒ Object
- .last_tag ⇒ Object
- .list_remotes ⇒ Object
- .outstanding_commit ⇒ Object
- .remote_urls ⇒ Object
- .remote_urls=(urls) ⇒ Object
- .scan_remote_urls ⇒ Object
- .user_can_commit ⇒ Object
- .user_email ⇒ Object
- .user_name ⇒ Object
Instance Attribute Details
#start_time ⇒ Object
Returns the value of attribute start_time.
3 4 5 |
# File 'lib/raykit/git.rb', line 3 def start_time @start_time end |
Class Method Details
.add_remote ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/raykit/git.rb', line 46 def self.add_remote remote = get_remote if(remote.length > 0) #if(Dir.exist?('.git')) #cmd = Command.new #cmd.command = 'git config --get remote.origin.url' #cmd.run #remote = cmd.output.strip remote_urls_copy = remote_urls if(!remote_urls_copy.include?(remote)) remote_urls_copy.insert(0,remote) Git::remote_urls = remote_urls_copy end end end |
.branch ⇒ Object
5 6 7 8 |
# File 'lib/raykit/git.rb', line 5 def self.branch branches = `git branch` branches.match(/ ([\w.]+)/).captures[0] end |
.get_remote ⇒ Object
36 37 38 39 40 41 42 43 44 45 |
# File 'lib/raykit/git.rb', line 36 def self.get_remote if(Dir.exist?('.git')) cmd = Command.new cmd.command = 'git config --get remote.origin.url' cmd.run return cmd.output.strip else `` end end |
.last_tag ⇒ Object
10 11 12 |
# File 'lib/raykit/git.rb', line 10 def self.last_tag `git describe --abbrev=0 --tags`.strip end |
.list_remotes ⇒ Object
78 79 80 |
# File 'lib/raykit/git.rb', line 78 def self.list_remotes remote_urls.each{|url| puts url} end |
.outstanding_commit ⇒ Object
28 29 30 31 32 33 34 |
# File 'lib/raykit/git.rb', line 28 def self.outstanding_commit if(Git::user_can_commit) return !`git status`.include?('nothing to commit,') else return false end end |
.remote_urls ⇒ Object
62 63 64 65 66 67 68 69 |
# File 'lib/raykit/git.rb', line 62 def self.remote_urls filename="#{Environment::log_dir}/Raykit.Git.RemoteUrls.json"; if(File.exist?(filename)) JSON.parse(File.read(filename)) else Array.new end end |
.remote_urls=(urls) ⇒ Object
71 72 73 74 75 76 |
# File 'lib/raykit/git.rb', line 71 def self.remote_urls=(urls) filename="#{Environment::log_dir}/Raykit.Git.RemoteUrls.json" File.open(filename,'w'){|f| f.write(JSON.generate(urls)) } end |
.scan_remote_urls ⇒ Object
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 |
# File 'lib/raykit/git.rb', line 82 def self.scan_remote_urls remotes = Array.new git_dirs = Array.new Dir.chdir(Environment::work_dir) do Dir.glob('**/.git'){|git_dir| dir = File.('..',git_dir) if(dir.length > 0) git_dirs.insert(0,dir) end } end git_dirs.each{|git_dir| Dir.chdir(git_dir) do remote = get_remote if(remote.length > 0) remotes.insert(0,remote) end end } remotes end |
.user_can_commit ⇒ Object
22 23 24 25 26 |
# File 'lib/raykit/git.rb', line 22 def self.user_can_commit return false if(user_name.length == 0) return false if(user_email.length == 0) return true end |
.user_email ⇒ Object
18 19 20 |
# File 'lib/raykit/git.rb', line 18 def self.user_email return `git config --get user.email`.strip end |
.user_name ⇒ Object
14 15 16 |
# File 'lib/raykit/git.rb', line 14 def self.user_name return `git config --get user.name`.strip end |