def publish(): entity_location = os.getcwd() if check_for_cor(): username = gc.github_login().get_user().login sync_backend() remote = gc.getremote() localindex = gc.get_cor_index() if localindex is None: localindex = gc.fork_on_github("bahusvel/COR-Index") if not os.path.exists(STORAGE_LOCAL_INDEX): os.chdir(CORCLISTORAGE) gc.gitclone(localindex.clone_url, aspath="localindex") os.chdir(STORAGE_LOCAL_INDEX) gc.gitpull() # create corfile here local_cordict = read_corfile(entity_location + "/.cor/corfile.json") local_cordict["repo"] = remote if local_cordict["type"] == "MODULE": prefix = "modules" elif local_cordict["type"] == "FRAMEWORK": prefix = "frameworks" else: raise Exception(local_cordict["type"] + "is an invalid type") public_name = local_cordict["name"].lower() public_corfile_path = STORAGE_LOCAL_INDEX+"/" + prefix + "/" + public_name + ".json" write_corfile(local_cordict, public_corfile_path) gc.gitadd(public_corfile_path) gc.gitcommit("Added " + public_name) gc.gitpush() try: gc.github_pull_request(localindex.full_name, username, "COR-Index", "Add " + public_name) except Exception: click.secho("Pull request failed, please create one manualy", err=True) else: click.secho("Not a COR-Entity (Framework, Module, Recipe)", err=True)
def sync_backend(): commited = False if check_for_cor(): if gc.getremote() != "": if gc.isdiff(): if click.confirm("You have modified the module do you want to commit?"): msg = click.prompt("Please enter a commit message") gc.gitupsync(msg) commited = True gc.gitpull() if commited: gc.gitpush() else: click.secho("You do not have git remote setup", err=True) if click.confirm("Do you want one setup automatically?"): gc.github_login() name = read_corfile(os.getcwd() + "/.cor/corfile.json")["name"] remote = gc.github_create_repo(name).clone_url else: click.secho("You will have to create a repository manually and provide the clone url") remote = click.prompt("Please enter the url") gc.addremote(remote) gc.gitadd(".") gc.gitcommit("Initlizaing repo") gc.gitpush(create_branch=True) else: click.secho("Not a COR-Entity (Framework, Module, Recipe)", err=True)