#NEWLINE# def main( args = None ) : #NEWLINE# #INDENT# 'Push this package and its\' dependencies to a remote git repositories.\n\n  Gather the git repository of this package and its\' dependencies, specified\n  by a JSON configuration file, and push the result to a remote git repository.\n  In addition, create a "master" branch on the remote that contains this\n  package\'s dependencies under the "dependencies" directory as submodules.\n  Finally, build the documentation using the "docs/generate_docs.py" script for\n  this package and push the HTML output to a "gh-pages" branch in the remote\n  repo.\n\n  Args:\n    args: The result of parse_arguments().\n\n  Returns:\n    0 if all dependencies are found, 1 otherwise.\n  ' #NEWLINE# args = ( args if args else parse_arguments ( ) ) #NEWLINE# subprocess_runner = Subprocess ( ) #NEWLINE# if args . staging_area : #NEWLINE# #INDENT# working_copy = os . path . realpath ( args . staging_area ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# working_copy = tempfile . mkdtemp ( ) #NEWLINE# #UNINDENT# project_name = os . path . basename ( args . package_dir ) #NEWLINE# working_copy = os . path . join ( working_copy , project_name ) #NEWLINE# os . mkdir ( working_copy ) #NEWLINE# logging . basicConfig ( format = '%(message)s' ) #NEWLINE# logging . getLogger ( ) . setLevel ( ( logging . DEBUG if args . verbose else logging . INFO ) ) #NEWLINE# if args . create_mirror : #NEWLINE# #INDENT# logging . info ( 'mirror target directory: %s' , args . create_mirror ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( args . verbose or args . leave_working_copy ) : #NEWLINE# #INDENT# logging . info ( 'git staging area in: %s' , working_copy ) #NEWLINE# #UNINDENT# #UNINDENT# try : #NEWLINE# #INDENT# subprocess_runner . check_call ( [ 'git' , 'init' ] , cwd = working_copy ) #NEWLINE# try : #NEWLINE# #INDENT# config_path = os . path . relpath ( args . config_json , args . package_dir ) #NEWLINE# package = Package . parse_json ( read_config ( args . config_json ) , config_path , args . package_dir , subprocess_runner , working_copy , read_config ) #NEWLINE# #UNINDENT# except ( ConfigJsonError , DependencyNotFoundError ) as error : #NEWLINE# #INDENT# logging . error ( str ( error ) ) #NEWLINE# return 1 #NEWLINE# #UNINDENT# if args . create_mirror : #NEWLINE# #INDENT# display_package ( package , logging . info ) #NEWLINE# package . create_mirror ( args . create_mirror ) #NEWLINE# return 0 #NEWLINE# #UNINDENT# try : #NEWLINE# #INDENT# logging . info ( '===== Adding Remotes ====' ) #NEWLINE# package . add_all_git_remotes ( args . remote_name ) #NEWLINE# display_package ( package , logging . debug ) #NEWLINE# logging . info ( '===== Fetching Remotes ====' ) #NEWLINE# package . fetch_all_remotes ( ) #NEWLINE# logging . info ( '===== Pushing Dependencies ====' ) #NEWLINE# package . push_git_project_and_dependencies ( args . local_branch , args . dryrun ) #NEWLINE# logging . info ( '===== Updating Master ====' ) #NEWLINE# package . update_master ( args . local_branch , args . master_branch , args . dryrun ) #NEWLINE# logging . info ( '===== Updating Docs ====' ) #NEWLINE# package . update_docs ( args . local_branch , args . docs_branch , ( args . dryrun or ( not args . push_docs ) ) ) #NEWLINE# #UNINDENT# finally : #NEWLINE# #INDENT# if ( not args . leave_working_copy ) : #NEWLINE# #INDENT# package . delete_temporary_git_objects ( ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# finally : #NEWLINE# #INDENT# if ( ( not args . leave_working_copy ) and ( not args . staging_area ) ) : #NEWLINE# #INDENT# shutil . rmtree ( working_copy ) #NEWLINE# #UNINDENT# #UNINDENT# return 0