Class: Issuesrc::Sourcers::GitSourcer

Inherits:
Object
  • Object
show all
Defined in:
lib/sourcers/git_sourcer.rb

Direct Known Subclasses

GithubSourcer

Instance Method Summary collapse

Constructor Details

#initialize(args, config) ⇒ GitSourcer

Returns a new instance of GitSourcer.


11
12
13
14
15
16
17
18
19
20
21
# File 'lib/sourcers/git_sourcer.rb', line 11

def initialize(args, config)
  if @url.nil?
    @url = try_find_repo_url(args, config)
  end

  if @url.nil?
    @path = try_find_repo_path(args, config)
  end

  init(args, config)
end

Instance Method Details

#finish(created_tags, updated_tags, closed_issues) ⇒ Object


51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/sourcers/git_sourcer.rb', line 51

def finish(created_tags, updated_tags, closed_issues)
  if created_tags.empty? && closed_issues.empty?
    return
  end

  msg = make_commit_message(created_tags, updated_tags, closed_issues)
  $stderr.puts msg

  if @commit_when_done
    make_commit(msg)
  end
  
  if @push_when_done
    push_repo()
  end

  if @tmp_dir
    FileUtils.remove_entry_secure @tmp_dir
  end
end

#initialize_with_path(path, args, config) ⇒ Object


28
29
30
31
# File 'lib/sourcers/git_sourcer.rb', line 28

def initialize_with_path(path, args, config)
  @path = path
  init(args, config)
end

#initialize_with_url(url, args, config) ⇒ Object


23
24
25
26
# File 'lib/sourcers/git_sourcer.rb', line 23

def initialize_with_url(url, args, config)
  @url = url
  init(args, config)
end

#retrieve_filesObject


33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/sourcers/git_sourcer.rb', line 33

def retrieve_files()
  dir = nil
  if !@url.nil?
    tmp_dir = Dir::mktmpdir
    @tmp_dir = tmp_dir
    dir = clone_repo(tmp_dir)
    @path = dir
  else
    dir = @path
  end

  Enumerator.new do |enum|
    find_all_files(dir) do |file|
      enum << file
    end
  end
end