#NEWLINE# def create_build( project , collection_id , label , target , message , author , change = None , patch = None , cause = None , source = None , sha = None , source_data = None , tag = None , snapshot_id = None , no_snapshot = False ) : #NEWLINE# #INDENT# assert ( sha or source ) #NEWLINE# repository = project . repository #NEWLINE# if ( source is None ) : #NEWLINE# #INDENT# if patch : #NEWLINE# #INDENT# ( source , _ ) = get_or_create ( Source , where = { #NEWLINE# #INDENT# 'patch' : patch , #NEWLINE# #UNINDENT# } , defaults = { #NEWLINE# #INDENT# 'repository' : repository , #NEWLINE# 'revision_sha' : sha , #NEWLINE# 'data' : ( project or { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } ) , #NEWLINE# #UNINDENT# } ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# ( source , _ ) = get_or_create ( Source , where = { #NEWLINE# #INDENT# 'repository' : repository , #NEWLINE# 'patch' : None , #NEWLINE# 'revision_sha' : sha , #NEWLINE# #UNINDENT# } , defaults = { #NEWLINE# #INDENT# 'data' : ( source_data or { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } ) , #NEWLINE# #UNINDENT# } ) #NEWLINE# #UNINDENT# #UNINDENT# statsreporter . stats ( ) . incr ( 'new_api_build' ) #NEWLINE# build = Build ( project = project , project_id = project . id , collection_id = collection_id , source = source , source_id = ( source . id if source else None ) , status = Status . queued , author = author , author_id = ( author . id if author else None ) , label = label , target = target , message = message , cause = cause , tags = ( [ tag ] if tag else [ ] ) ) #NEWLINE# db . session . add ( build ) #NEWLINE# db . session . commit ( ) #NEWLINE# execute_build ( build = build , snapshot_id = snapshot_id , no_snapshot = no_snapshot ) #NEWLINE# return build