Module: NeetoTranslateCli::GitHelper

Defined in:
lib/neeto_translate_cli/git_helper.rb

Class Method Summary collapse

Class Method Details

.find_neeto_translate_commitObject



5
6
7
8
9
10
11
12
13
# File 'lib/neeto_translate_cli/git_helper.rb', line 5

def self.find_neeto_translate_commit
  result = `git log --grep="[neeto-translate]" --fixed-strings -n 1 --pretty=format:"%H"`.strip

  if result.empty?
    result = progressive_fetch
  end

  result
end

.progressive_fetchObject



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/neeto_translate_cli/git_helper.rb', line 17

def self.progressive_fetch
  puts "No neeto-translate commits found, fetching depth 50..."
  `git fetch --depth=50 2>/dev/null`
  result = `git log --grep="[neeto-translate]" --fixed-strings -n 1 --pretty=format:"%H"`.strip

  return result unless result.empty?

  puts "Still no commits found, fetching depth 100..."
  `git fetch --depth=100 2>/dev/null`
  result = `git log --grep="[neeto-translate]" --fixed-strings -n 1 --pretty=format:"%H"`.strip

  return result unless result.empty?

  puts "Still no commits found, fetching depth 500..."
  `git fetch --depth=500 2>/dev/null`
  result = `git log --grep="[neeto-translate]" --fixed-strings -n 1 --pretty=format:"%H"`.strip

  return result unless result.empty?

  puts "Still no commits found, fetching full history..."
  `git fetch --unshallow 2>/dev/null`
  `git log --grep="[neeto-translate]" --fixed-strings -n 1 --pretty=format:"%H"`.strip
end