Exemple #1
0
def publish():
	entitypath = os.getcwd()
	username = gc.github_login().get_user().login
	sync_backend()
	localindex = gc.get_appsource_index()
	if localindex is None:
		localindex = gc.fork_on_github("bahusvel/AppSource-Index")
	if not os.path.exists(STORAGE_LOCAL_INDEX):
		os.chdir(APPSTORAGE)
		gc.gitclone(localindex.clone_url, aspath="localindex")
	os.chdir(STORAGE_LOCAL_INDEX)
	gc.gitpull()
	# create corfile here
	app_dict = {}
	app_id = click.prompt("Please enter the App ID for your application")
	app_dict["name"] = app_id[app_id.rfind(".")+1:]
	app_dict["description"] = click.prompt("Please enter a short description for your app")
	os.chdir(entitypath)
	app_dict["repo"] = gc.getremote()
	public_appfile_path = STORAGE_LOCAL_INDEX+"/ios/" + app_id + ".json"
	write_appfile(app_dict, public_appfile_path)
	os.chdir(STORAGE_LOCAL_INDEX)
	gc.gitadd(public_appfile_path)
	gc.gitcommit("Added " + app_id)
	gc.gitpush()
	try:
		gc.github_pull_request(localindex.full_name, username, "AppSource-Index", "Add " + app_id)
	except Exception:
		click.secho("Pull request failed, please create one manualy", err=True)
Exemple #2
0
def sync_backend():
	commited = False
	if not os.path.exists(".git"):
		if click.confirm("This is not a git repository, would you like to initialize it as git?", default=True):
			gc.gitinit()
		else:
			click.secho("Operation aborted", err=True)
			exit(1)
	if gc.getremote() != "":
		if gc.isdiff():
			if click.confirm("You have modified the app 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 = click.prompt("Please enter the name for the repo")
			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("Initializing repo")
		gc.gitpush(create_branch=True)