Class: Pj::Base

Inherits:
Thor
  • Object
show all
Defined in:
lib/pj/base.rb

Instance Method Summary collapse

Instance Method Details

#cd(project = nil) ⇒ Object



45
46
47
48
49
50
51
52
# File 'lib/pj/base.rb', line 45

def cd(project = nil)
  project = self_class_name if project.nil?
  repo_dir = repo_dir(project)
  cmd = "cd #{repo_dir}"
  Clipboard.copy cmd
  puts "#{cmd} copied to your clipboard. Paste and change directory"
  cmd
end

#owner(project = nil, branch = "master") ⇒ Object



32
33
34
35
36
37
38
39
40
41
42
# File 'lib/pj/base.rb', line 32

def owner(project = nil, branch = "master")
  project = self_class_name if project.nil?
  repo = Pj::Git.new project
  if repo.upstream? && repo.origin?
    repo.check_commit
    repo.push("origin", branch)
    repo.push("upstream", branch)
  else
    puts "Nothing to do. You don't have origin && upstream"
  end
end

#push(project = nil, branch = "master") ⇒ Object



23
24
25
26
27
28
# File 'lib/pj/base.rb', line 23

def push(project = nil, branch = "master")
  project = self_class_name if project.nil?
  repo = Pj::Git.new project
  repo.check_commit
  repo.push("origin", branch)
end

#sync(project = nil) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
# File 'lib/pj/base.rb', line 9

def sync(project = nil)
  project = self_class_name if project.nil?
  repo = Pj::Git.new project
  if repo.upstream?
    repo.git "fetch upstream"
    repo.check_commit
    repo.git "merge upstream/master"
  else
    puts "Nothing to do. You don't have any upstream to sync"
  end
end