Module: Files::Perforce

Defined in:
lib/specss/files.rb

Class Method Summary collapse

Class Method Details

.get_changelist_filesObject

Returns all ruby files in changelist as an array of files without extension



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/specss/files.rb', line 7

def self.get_changelist_files
  changed_files = []
  p4_status = %x|p4 status &|

  if p4_status.empty?
    puts 'Please install perforce command line client: '\
         'https://www.perforce.com/perforce/r14.2/manuals/p4guide/chapter.install.html'
    return false
  end

  p4_array = p4_status.split("\n")

  # Add all ruby files ready to be submitted to changed file array
  p4_array.each do |p|
    next unless p.include?('.rb')
    file = p.split(' - ')[0]
    status = p.split(' - ')[1]
    changed_files.push(File.basename(file, ".*")) if status.include? 'submit'
  end
  changed_files
end