Class: Arcanist
- Inherits:
-
Struct
- Object
- Struct
- Arcanist
- Defined in:
- lib/arcanist.rb
Instance Attribute Summary collapse
-
#cert ⇒ Object
Returns the value of attribute cert.
-
#conduit_uri ⇒ Object
Returns the value of attribute conduit_uri.
-
#user ⇒ Object
Returns the value of attribute user.
Instance Method Summary collapse
Instance Attribute Details
#cert ⇒ Object
Returns the value of attribute cert
7 8 9 |
# File 'lib/arcanist.rb', line 7 def cert @cert end |
#conduit_uri ⇒ Object
Returns the value of attribute conduit_uri
7 8 9 |
# File 'lib/arcanist.rb', line 7 def conduit_uri @conduit_uri end |
#user ⇒ Object
Returns the value of attribute user
7 8 9 |
# File 'lib/arcanist.rb', line 7 def user @user end |
Instance Method Details
#diff(work_dir, callsign, commit: 'HEAD^', differential_id: nil, message: nil, reviewers: '') ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/arcanist.rb', line 9 def diff work_dir, callsign, commit: 'HEAD^', differential_id: nil, message: nil, reviewers: '' arcrc = write_arcrc temps = [arcrc] args = ['--no-ansi', '--conduit-uri', conduit_uri, '--config', "repository.callsign=#{callsign}", '--arcrc-file', arcrc.path] if differential_id # update existing diff args += ['--update', differential_id.to_s, '--message', || 'Update'] else # create new diff tmp = Tempfile.create 'arcmsg' tmp.write <<"EOS" #{ || Git::(work_dir)} Test Plan: N/A (imported by gerricator) Reviewers: #{[*reviewers].join(', ')} EOS tmp.flush temps << tmp args += ['--create', '--message-file', tmp.path] end Dir.chdir work_dir do cmd = Shellwords.join(['arc', 'diff', *args, commit]) result = `#{cmd}` if not differential_id differential_id = result[/#{File.join(conduit_uri, 'D')}(\d+)/, 1] end end differential_id ensure temps.each do |t| File.unlink(t) if t && File.exists?(t) end end |