module HelixSync # Front end to managing changelist-related resources. # # This doesn't actually provide implementations, just hooks for other services. class ChangeService # Rack environment attr_accessor :env def initialize(env: nil) @env = env end @@create_pending_change = [] @@fetch_latest_change = [] @@fetch_pending_change = [] @@submit_pending_change = [] # Callback list for finding the latest changelist for a project. # # Your handler should return the changelist if your implementation supports # this particular project. # # Each callback you add should consume these parameters: # # - `project` [String]: The encoded project ID # # - `env` [Hash]: Current Rack environment # # Example: # # HelixSync::ChangeService.fetch_change << lambda do |project, env| # fetch_change(project, env) if i_support?(project) # end def self.fetch_latest_change @@fetch_latest_change end # Returns the change found by the first handler that supports the project, # or nil def find_latest_change(project_id) change_num = nil @@fetch_latest_change.find do |handler| c = handler.call(project_id, env) change_num = c if c c end change_num end # Callback list for finding the pending changelist for a project. # # Your handler should return the changelist if your implementation supports # this particular project. # # Each callback you add should consume these parameters: # # - `project` [String]: The encoded project ID # # - `env` [Hash]: Current Rack environment # # Example: # # HelixSync::ChangeService.fetch_change << lambda do |project, env| # fetch_change(project, env) if i_support?(project) # end def self.fetch_pending_change @@fetch_pending_change end # Returns the change found by the first handler that supports the project, # or nil def find_pending_change(project_id) change_num = nil @@fetch_pending_change.find do |handler| c = handler.call(project_id, env) change_num = c if c c end change_num end # Callback list for creating a pending changelist # # Your handler should return the changelist if your implementation handled # creating the changelist number. # # Each callback you add should consume these parameters: # # - `project` [String]: The encoded project ID # # - `env` [Hash]: Current Rack environment # # Example: # # HelixSync::ChangeService.create_pending_change << lambda do |project, env| # create_change(project, env) if i_support?(project) # end # def self.create_pending_change @@create_pending_change end # Returns the new pending change for the user and project ID def create_pending_change(project_id) change_num = nil @@create_pending_change.find do |handler| c = handler.call(project_id, env) change_num = c if c c end change_num end # Callback list for submitting a pending changelist for a project # # Your handler should return the changelist if your implementation handled # creating the changelist number. # # Each callback you add should consume these parameters: # # - `project` [String]: The encoded project ID # # - `env` [Hash]: Current Rack environment # # Example: # # HelixSync::ChangeService.submit_pending_change << lambda do |project, changelist, env| # create_change(project, changelist, env) if i_support?(project) # end # def self.submit_pending_change @@submit_pending_change end def submit_pending_change(project_id) @@submit_pending_change.find do |handler| handler.call(project_id, env) end end end end
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#1 | 15741 | ptomiak | Branch HWS for my use. | ||
//guest/perforce_software/helix-web-services/main/source/helix_web_services/lib/helix_sync/change_service.rb | |||||
#1 | 15622 | tjuricek |
Move source code to 'source/' subdirectory of branch. build/ will remain where it is. |
||
//guest/perforce_software/helix-web-services/main/helix_web_services/lib/helix_sync/change_service.rb | |||||
#5 | 15517 | tjuricek | Do not require changelist ID for submitting Helix Sync pending changelists. | ||
#4 | 15499 | tjuricek | Naive implementation of helix sync project submit for "helix versioning engine projects". | ||
#3 | 15497 | tjuricek | Add support to fetch the latest change of a project. | ||
#2 | 15496 | tjuricek |
Revise GET /helix_sync/v1/changes/[project] to /helix_sync/v1/changes/[project]/pending The base method is really intended for the latest changelist number. Meh. |
||
#1 | 15487 | tjuricek | Add basic ability to create pending changelists for helix sync projects. |