def merger(source, target, close): """Merge branch in all repositories""" # We can't mix multiple+prompt in click options, so we do it by hand if not source: source = [ click.prompt('Source', default='devel', show_default=True, type=str) ] if not target: target = click.prompt('Target', type=str) repositories_github = app.get_exo_repositories_github() for src in source: if src == "devel" or src == "master" or "EPIC" in src: close = False if src == "devel" and "hotfix" in target: click.confirm('Are you sure of merging devel in a hotfix?', abort=True) for repo_slug in repositories_github: print("Merging %s into %s in %s repository" % (source, target, repo_slug)) try: app.merge_branch_github(repo_slug, source, target, close) except Exception as e: print( "Error merging branch %s into %s on %s github repository.\n %s\n" % (source, target, repo_slug, str(e)))
def deleter(source): """Delete branch in all repositories""" if source == "devel" or source == "master": print("You can't delete '%s' branch" % source) exit() for repo_slug in app.get_exo_repositories_github(): try: app.delete_branch_github(repo_slug, source) except Exception as e: print("Error deleting branch %s in %s github repository.\n %s\n" % (source, repo_slug, str(e)))
def tagger(tag): """Tag master in all repositories""" if click.confirm( 'CAUTION: Are you sure to want tag directly instead of call releaser?' ): for repo_slug in app.get_exo_repositories_github(): print("Tagging %s in %s repository" % (tag, repo_slug)) try: app.tag_repository_github(repo_slug, tag) except Exception as e: print( "Error tagging branch %s in %s github repository.\n %s\n" % (tag, repo_slug, str(e)))
def releaser(tag): """Merge a release branch in devel and master and tag master""" if not check_status("release-" + tag): exit(1) repositories_github = app.get_exo_repositories_github() error_flag = False source_branch = "release-%s" % tag for repo_slug in repositories_github: print("Merging %s into %s in %s repository" % (source_branch, "devel", repo_slug)) try: app.merge_branch_github(repo_slug, source_branch, "devel", False) except Exception as e: print( "Error merging branch %s into %s on %s github repository.\n %s\n" % (source_branch, "devel", repo_slug, str(e))) error_flag = True if not error_flag: for repo_slug in repositories_github: print("Merging %s into %s in %s repository" % (source_branch, "master", repo_slug)) try: app.merge_branch_github(repo_slug, source_branch, "master", True) except Exception as e: print( "Error merging branch %s into %s on %s github repository.\n %s\n" % (source_branch, "master", repo_slug, str(e))) error_flag = True if not error_flag: for repo_slug in repositories_github: print("Tagging %s in %s repository" % (tag, repo_slug)) try: app.tag_repository_github(repo_slug, tag) except Exception as e: print( "Error tagging branch %s in %s github repository.\n %s\n" % (tag, repo_slug, str(e)))
def brancher(issue, name, source): """Create branches in all repositories""" if issue: name = "%s-MVF" % (issue) if name: if source is 'devel' and (name.startswith('feature/') or name.startswith('release-')): click.secho( 'Notice: This is a feature or release branch, forcing "master" as source branch.', fg='yellow') source = 'master' for repo_slug in app.get_exo_repositories_github(): print("Creating %s branch in %s repository" % (name, repo_slug)) try: app.create_branch_github(repo_slug, source, name) except Exception as e: print( "Error creating branch %s in %s github repository.\n %s\n" % (name, repo_slug, str(e))) else: click.secho("ERROR: You must indicate --issue or --name", fg='red')
def list_exo_repositories(): """Print the ExO Lever repo list""" click.secho("GitHub:", fg='yellow') for repo_slug in app.get_exo_repositories_github(): print(" - %s" % repo_slug)