Class: T1k::Commands::Sink

Inherits:
Object
  • Object
show all
Defined in:
lib/t1k/commands/sink.rb

Class Method Summary collapse

Class Method Details

.commands_if_branch(branch) ⇒ Object



29
30
31
32
33
34
35
# File 'lib/t1k/commands/sink.rb', line 29

def self.commands_if_branch(branch)
  [ "git checkout #{branch}",
    "git pull --rebase",
  ].each do |cmd|
    system cmd
  end
end

.commands_if_master(branch) ⇒ Object



19
20
21
22
23
24
25
26
27
# File 'lib/t1k/commands/sink.rb', line 19

def self.commands_if_master(branch)
  [ "git checkout master",
    "git pull --rebase origin master",
    "git checkout #{branch.strip}",
    "git rebase master #{branch.strip}"
  ].each do |cmd|
    system cmd
  end
end

.runObject



4
5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/t1k/commands/sink.rb', line 4

def self.run
  T1k.setup_credentials

  default_remote_branch = T1k::Repository.default_remote_branch
  branch                = T1k::Commands::Branch.actual_branch

  if default_remote_branch == :master
    commands_if_master(branch)
  elsif default_remote_branch == :branch
    commands_if_branch(branch)
  else
    puts "Invalid default_remote_branch"
  end
end