Module: Jumpup::GitCommand

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

Class Method Summary collapse

Class Method Details

.check_integrationObject



40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/jumpup/commands/git_command.rb', line 40

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

.check_last_commit_changeObject



28
29
30
31
32
33
34
# File 'lib/jumpup/commands/git_command.rb', line 28

def check_last_commit_change
  Jumpup::UI.say '  --> Checking if last commit changed since integration started...'.yellow
  if last_commit_hash != stored_commit_hash
    Jumpup::UI.say "  --> Last commit changed since integration started. Halting!".red
    exit
  end
end

.lock_integrationObject



60
61
62
63
64
65
# File 'lib/jumpup/commands/git_command.rb', line 60

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

.reset_commit_hash!Object



36
37
38
# File 'lib/jumpup/commands/git_command.rb', line 36

def reset_commit_hash!
  @@last_commit_hash = ''
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

.store_last_commit_hashObject



23
24
25
26
# File 'lib/jumpup/commands/git_command.rb', line 23

def store_last_commit_hash
  Jumpup::UI.say '  --> Storing last commit hash...'.yellow
  @@last_commit_hash = last_commit_hash
end

.unlock_integrationObject



67
68
69
70
71
72
# File 'lib/jumpup/commands/git_command.rb', line 67

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