require 'helix_web_services_client' require 'helix_versioning_engine/util' module HelixVersioningEngine # Used to obtain consistent output to "files" commands and return output in # our model format for consumption by other services. class FileService attr_reader :p4 def initialize(p4: nil) @p4 = p4 end def list(dirs) if dirs.nil? || dirs.empty? list_depots else list_dir(dirs) end end def list_depots results = p4.run_depots normalize_depots(results) results.map{ |r| HelixWebServicesClient::Models::Depot.new(r) } end def list_file(file_path) files_results = nil p4.at_exception_level(P4::RAISE_NONE) do files_results = p4.run_files(file_path) end normalize_files(files_results) results = files_results[0] return nil unless results print_results = p4.run_print(file_path) results['Content'] = Base64.encode64(print_results[1]) HelixWebServicesClient::Models::File.new(results) end def list_dir(dirs) file_selector = '//' + dirs.join('/') files_results = nil p4.at_exception_level(P4::RAISE_NONE) do files_results = p4.run_files(file_selector) end files_results = [] unless files_results return_val = nil if files_results.length == 1 && files_results.first.key?('depotFile') && files_results.first['depotFile'] == file_selector # Treat request like a single file GET normalize_files(files_results) results = files_results[0] print_results = p4.run_print(file_selector) results['Content'] = Base64.encode64(print_results[1]) return_val = HelixWebServicesClient::Models::File.new(results) else # Treat request like a directory list selector = '//' + dirs.join('/') + '/*' files_results = p4.run_files('-e', selector) normalize_files(files_results) items = files_results.map { |f| HelixWebServicesClient::Models::File.new(f) } dirs_results = p4.run_dirs(selector) normalize_dirs(dirs_results) dirs = dirs_results.map { |d| HelixWebServicesClient::Models::Dir.new(d) } items.concat(dirs) return_val = items end return_val end def normalize_depots(results) @normalize_depots ||= Util.normalizer('depots', offset) @normalize_depots.call(results) end def normalize_files(results) @normalize_files ||= Util.normalizer('files', offset) @normalize_files.call(results) end def normalize_dirs(results) @normalize_dirs ||= Util.normalizer('dirs', offset) @normalize_dirs.call(results) end def offset @offset ||= fetch_offset end def fetch_offset results = p4.run_info Util.p4_date_offset(results[0]['serverDate']) end end end
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#2 | 15622 | tjuricek |
Move source code to 'source/' subdirectory of branch. build/ will remain where it is. |
||
#1 | 15032 | tjuricek |
Starting config and doc revisions. System is now broken while revisions underway. Configuration of the p4d connection is now done via a single HWSSettings middleware object injected into the Rack env. The HWSP4Cleanup middleware now cleans up any p4 injected into the Rack env. The Auth::App class now mostly just contains one method to generate a p4 ticket. /auth/v1/login. Added yard documentation for the main project. Yard docs have been reconfigured to dump into build/ directories. This should probably be done with each release. Hm... The top level rake file contains a task, 'all:doc', to update our documentation. This should probably be run for each checkin. Hm... Specs are now using Rack::Test on top of a 'live' p4d. I'd suggest you still use the p4util mechanism, which now dumps to a /tmp folder, so we can safely add P4IGNORE rules back into your local .p4config file. Old 'perforce' application now called 'helix_versioning_engine'. Removing cache data. Helix Sync may be slow. It may also get axed. We'll see. |
||
//guest/perforce_software/helix-web-services/main/helix_web_services/lib/perforce/file_service.rb | |||||
#3 | 13891 | tjuricek |
Added a 'member' concept to projects. members is the start of a basic project 'role' definition. In Helix sync, this is mostly just used to indicate this is a "my Project" in the UI and a project member can have the ability to leave the project or add someone else. Eventually, we expect "members" to mean more, like, is part of a group that has write access to the files of the project. But that sort of definition is very TBD. |
||
#2 | 13846 | tjuricek | Setup development rules for creating/initializing PostgreSQL, and updated some of the ProjectService specs. | ||
#1 | 13839 | tjuricek |
Conversion of the p4_project_service microservice to new monolithic system. This may not have an HTTP front end in the monolithic system. Project services are really just about how the core object model is structured. It's likely that each application will add their own wrinkles and extensions to the system, so it's unlikely we'll need a generic "project model". Exactly how extensions are registered and used is still a bit TBD at the moment. Previously they were to be registered webhooks, that model may change. Does not include tests yet. |