Skip to content

Commit

Permalink
working on resolving symlinks
Browse files Browse the repository at this point in the history
  • Loading branch information
dmalan committed Jan 3, 2018
1 parent cf6f36d commit a58ae11
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 12 deletions.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,5 +79,5 @@ class CustomInstall(install):
},
data_files=create_mo_files(),
url="https://github.com/cs50/submit50",
version="2.4.7"
version="2.4.8"
)
28 changes: 17 additions & 11 deletions submit50.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import argparse
import atexit
import base64
import datetime
import distutils
import gettext
Expand Down Expand Up @@ -453,24 +454,29 @@ def submit(org, branch):
except ValueError:
slug, src = branch, "cs50/checks"

# ensure slug exists
file, submit.EXCLUDE = tempfile.mkstemp()
url = "https://github.com/{}/raw/master/{}/submit50/exclude".format(src, slug)
# check for common mistakes
if slug.startswith("/") and slug.endswith("/"):
raise Error(_("Invalid slug. Did you mean {}, without the leading and trailing slashes?".format(slug.strip("/"))))
elif slug.startswith("/"):
raise Error(_("Invalid slug. Did you mean {}, without the leading slash?".format(slug.strip("/"))))
elif slug.endswith("/"):
raise Error(_("Invalid slug. Did you mean {}, without the trailing slash?".format(slug.strip("/"))))

# get slug's gitignore file
try:
urllib.request.urlretrieve(url, filename=submit.EXCLUDE)
lines = open(submit.EXCLUDE)
res = requests.get("https://api.github.com/repos/{}/contents/{}/submit50/exclude".format(src, slug),
headers={"Accept": "application/vnd.github.v3.raw"})
assert res.status_code == 200
fd, submit.EXCLUDE = tempfile.mkstemp()
with os.fdopen(fd, "w") as file:
file.write(res.text)
lines = res.text.splitlines()
except Exception as e:
if run.verbose:
cprint(str(e))
e = Error(_("Invalid slug. Did you mean to submit something else?"))
e.__cause__ = None
raise e
if slug.startswith("/") and slug.endswith("/"):
raise Error(_("Invalid slug. Did you mean {}, without the leading and trailing slashes?".format(slug.strip("/"))))
elif slug.startswith("/"):
raise Error(_("Invalid slug. Did you mean {}, without the leading slash?".format(slug.strip("/"))))
elif slug.endswith("/"):
raise Error(_("Invalid slug. Did you mean {}, without the trailing slash?".format(slug.strip("/"))))

# check for missing files
missing = []
Expand Down

0 comments on commit a58ae11

Please sign in to comment.