Class: HelixVersioningEngine::ChangeService
- Inherits:
-
Object
- Object
- HelixVersioningEngine::ChangeService
- Defined in:
- lib/helix_versioning_engine/change_service.rb
Overview
This class assists in creating changelists based on an array of file changes, some of which may be file uploads.
This is the implementation for file uploads and change creation.
Defined Under Namespace
Classes: File
Instance Attribute Summary (collapse)
-
- (Object) client_name
readonly
The name of the temporary client.
-
- (Object) client_root
readonly
The root directory of the temporary client.
-
- (Object) p4
readonly
The P4 connection we're using, that should already be logged in for a particular user.
Instance Method Summary (collapse)
-
- (ChangeService) initialize(p4: nil, client_name: nil, client_root: nil)
constructor
A new instance of ChangeService.
- - (Object) submit(files: [], description: 'Updating files')
Constructor Details
- (ChangeService) initialize(p4: nil, client_name: nil, client_root: nil)
Returns a new instance of ChangeService
21 22 23 24 25 |
# File 'lib/helix_versioning_engine/change_service.rb', line 21 def initialize(p4: nil, client_name: nil, client_root: nil) @p4 = p4 @client_name = client_name @client_root = client_root end |
Instance Attribute Details
- (Object) client_name (readonly)
The name of the temporary client
16 17 18 |
# File 'lib/helix_versioning_engine/change_service.rb', line 16 def client_name @client_name end |
- (Object) client_root (readonly)
The root directory of the temporary client
19 20 21 |
# File 'lib/helix_versioning_engine/change_service.rb', line 19 def client_root @client_root end |
- (Object) p4 (readonly)
The P4 connection we're using, that should already be logged in for a particular user.
13 14 15 |
# File 'lib/helix_versioning_engine/change_service.rb', line 13 def p4 @p4 end |
Instance Method Details
- (Object) submit(files: [], description: 'Updating files')
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/helix_versioning_engine/change_service.rb', line 27 def submit(files: [], description: 'Updating files') change_id = Util.init_changelist(p4, description) begin files = files.map { |f| f.is_a?(ChangeService::File) ? f : ChangeService::File.new(f) } collect_file_results(files) files.each { |f| f.call(p4, change_id, client_root) } p4.run_submit('-c', change_id) rescue StandardError => ex # Delete the changelist p4.at_exception_level(P4::RAISE_NONE) do p4.run_change('-d', '-f', change_id) if Util.error?(p4) puts "possible issues deleting change #{change_id}: #{p4.}" end end raise ex end end |