class Git::Daily::Command

Public Class Methods

branches() click to toggle source
# File lib/git-daily/command.rb, line 24
def self.branches
  r = `git branch --no-color`.split(/\n/)
  r.map! { |b| b[/^\*/] ? b[2 .. -1] : b.strip }
end
clean?() click to toggle source
# File lib/git-daily/command.rb, line 99
def self.clean?
  r = `git status -uno -s`.split(/\n/)
  r.empty? ? true : false
end
current_branch() click to toggle source
# File lib/git-daily/command.rb, line 78
def self.current_branch
  r = `git branch --no-color`.split(/\n/)
  master = r.select { |v| v[/^\*/] }
  return nil if master.empty?
  master[0][/^\* (.*)/, 1]
end
develop() click to toggle source
# File lib/git-daily/command.rb, line 46
def self.develop
  r = `git config gitdaily.develop`
  r.chomp!
  r.empty? ? nil : r
end
has_branch?(branch) click to toggle source
# File lib/git-daily/command.rb, line 29
def self.has_branch?(branch)
  r = branches
  r.find {|i| i == branch } ? true : false
end
has_remote_branch?(remote, branch) click to toggle source
# File lib/git-daily/command.rb, line 91
def self.has_remote_branch?(remote, branch)
  if remote_branch(remote, branch)
    true
  else
    false
  end
end
logurl() click to toggle source
# File lib/git-daily/command.rb, line 52
def self.logurl
  r = `git config gitdaily.logurl`
  r.chomp!
  r.empty? ? nil : r
end
master() click to toggle source
# File lib/git-daily/command.rb, line 40
def self.master
  r = `git config gitdaily.master`
  r.chomp!
  r.empty? ? nil : r
end
merged_branches() click to toggle source
# File lib/git-daily/command.rb, line 109
def self.merged_branches
  r = `git branch --no-color --merged`.split(/\n/)
  r.map! { |b| b[/^\*/] ? b[2 .. -1] : b.strip }
end
new() click to toggle source
# File lib/git-daily/command.rb, line 5
def initialize
end
pull_request_url() click to toggle source
# File lib/git-daily/command.rb, line 58
def self.pull_request_url
  r = `git config gitdaily.pullRequestUrl`
  r.chomp!

  return r unless r.empty?

  remote = self.remote
  if remote
    url_format = "https://github.com/%s/%s/pull/%s"
    github = `git config remote.#{remote}.url`
    github.chomp!

    github.match(/^git@github\.com:(?<org>.+)\/(?<repo>.+)\.git$/) do |match|
      r = sprintf(url_format, match[:org], match[:repo], "%d")
    end
  end

  r.empty? ? nil : r
end
release_branches(branch) click to toggle source
# File lib/git-daily/command.rb, line 104
def self.release_branches(branch)
  r = `git branch --no-color`.split(/\n/).select { |a| a[/#{branch}/] }
  r.map! { |b| b[/^\*/] ? b[2 .. -1] : b.strip }
end
remote() click to toggle source
# File lib/git-daily/command.rb, line 34
def self.remote
  r = `git config gitdaily.remote`
  r.chomp!
  r.empty? ? nil : r
end
remote_branch(remote, current_branch) click to toggle source
# File lib/git-daily/command.rb, line 85
def self.remote_branch(remote, current_branch)
  r = `git branch --no-color -a`.split(/\n/).select { |a| a[/remotes\/#{remote}\/#{current_branch}/] }
  return nil if r.empty?
  r[0].strip
end
remotes() click to toggle source
# File lib/git-daily/command.rb, line 20
def self.remotes
  `git config --list --no-color`.split(/\n/).select {|a| a[/^remote\.([^\.]+)\.url/] }
end

Public Instance Methods

help() click to toggle source
# File lib/git-daily/command.rb, line 12
def help
  raise NotImplementedError.new("You most implement help.")
end
run() click to toggle source
# File lib/git-daily/command.rb, line 8
def run
  raise NotImplementedError.new("You most implement run.")
end
usage() click to toggle source
# File lib/git-daily/command.rb, line 16
def usage
  raise NotImplementedError.new("You most implement usage.")
end