Module: Jumpup::GitCommand

Extended by:
Rake::DSL
Defined in:
lib/jumpup/commands/git_command.rb

Class Method Summary collapse

Class Method Details

.check_integrationObject



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/jumpup/commands/git_command.rb', line 23

def check_integration
  Jumpup::UI.say "  --> Checking if there's someone integrating...".yellow
  Jumpup::UI.say `git tag -d integrating`
  Jumpup::UI.say `git fetch --tags --quiet`

  tags = `git tag`.strip.split("\n")
  if tags.include?('integrating')
    tag_info = `git show integrating`
    integrating_by = /Tagger: (.*) <.*>/.match(tag_info)[1]
    if integrating_by == user
      Jumpup::UI.say "  --> Project is locked to you ('#{integrating_by}'), go ahead!".green
    else
      Jumpup::UI.say "  --> Project is already being integrated by '#{integrating_by}', halting!".red
      exit
    end
  else
    Jumpup::UI.say '  --> No, go ahead!'.green
  end
end

.lock_integrationObject



43
44
45
46
47
48
# File 'lib/jumpup/commands/git_command.rb', line 43

def lock_integration
  Jumpup::UI.say '  --> Locking integration...'.yellow
  Jumpup::UI.say `git tag -a -f integrating -m "Integration started at #{Time.now.strftime('%d/%m/%Y %T %Z')}"`
  Jumpup::UI.say `git push -f origin integrating --quiet`
  Jumpup::UI.say '  --> OK!'.green
end

.pullObject



15
16
17
# File 'lib/jumpup/commands/git_command.rb', line 15

def pull
  sh 'git pull --rebase --quiet'
end

.pushObject



19
20
21
# File 'lib/jumpup/commands/git_command.rb', line 19

def push
  sh 'git push --quiet'
end

.status_checkObject



8
9
10
11
12
13
# File 'lib/jumpup/commands/git_command.rb', line 8

def status_check
  result = `git status`
  return unless result.include?('Untracked files:') || result.include?('unmerged:') || result.include?('modified:')
  Jumpup::UI.say result
  exit
end

.unlock_integrationObject



50
51
52
53
54
55
# File 'lib/jumpup/commands/git_command.rb', line 50

def unlock_integration
  Jumpup::UI.say '  --> Unlocking integration...'.yellow
  Jumpup::UI.say `git tag -d integrating`
  Jumpup::UI.say `git push origin :refs/tags/integrating`
  Jumpup::UI.say '  --> OK!'.green
end