Skip to content

Commit

Permalink
Fix create and update github commands jayfk#264
Browse files Browse the repository at this point in the history
	- Change get_file_contents to get_contents
	- Remove beginning '/' on paths
  • Loading branch information
mrrsm committed Jul 15, 2020
1 parent 3dfcffc commit 17098cb
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions statuspage/statuspage.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,24 +143,24 @@ def run_upgrade(name, token, org):
with open(os.path.join(ROOT, "template", template), "r") as f:
content = f.read()
if template in files:
repo_template = repo.get_file_contents(
path="/" + template,
repo_template = repo.get_contents(
path=template,
ref=head_sha,
)
if not is_same_content(
content,
base64.b64decode(repo_template.content)
):
repo.update_file(
path="/" + template,
path=template,
sha=repo_template.sha,
message="upgrade",
content=content,
branch="gh-pages"
)
else:
repo.create_file(
path="/" + template,
path=template,
message="upgrade",
content=content,
branch="gh-pages"
Expand All @@ -176,8 +176,8 @@ def run_update(name, token, org):
sha = repo.get_git_ref("heads/gh-pages").object.sha

# get the template from the repo
template_file = repo.get_file_contents(
path="/template.html",
template_file = repo.get_contents(
path="template.html",
ref=sha
)

Expand All @@ -195,8 +195,8 @@ def run_update(name, token, org):
# create/update the index.html with the template
try:
# get the index.html file, we need the sha to update it
index = repo.get_file_contents(
path="/index.html",
index = repo.get_contents(
path="index.html",
ref=sha,
)

Expand All @@ -205,7 +205,7 @@ def run_update(name, token, org):
return False

repo.update_file(
path="/index.html",
path="index.html",
sha=index.sha,
message="update index",
content=content,
Expand All @@ -214,7 +214,7 @@ def run_update(name, token, org):
except UnknownObjectException:
# index.html does not exist, create it
repo.create_file(
path="/index.html",
path="index.html",
message="initial",
content=content,
branch="gh-pages",
Expand Down Expand Up @@ -317,7 +317,7 @@ def get_config(repo):
config = DEFAULT_CONFIG
if "config.json" in files:
# get the config file, parse JSON and merge it with the default config
config_file = repo.get_file_contents('config.json', ref="gh-pages")
config_file = repo.get_contents('config.json', ref="gh-pages")
try:
repo_config = json.loads(config_file.decoded_content.decode("utf-8"))
config.update(repo_config)
Expand Down

0 comments on commit 17098cb

Please sign in to comment.