-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fetch and pull branches if local copies of student repos already exist #89
Conversation
323d745
to
c2daaeb
Compare
@brhoades I re-did the progress bar method; this is a bit less bad I think? |
c2daaeb
to
297b16b
Compare
assigner/commands/get.py
Outdated
|
||
progress = tqdm() | ||
|
||
for i,student in progress.enumerate(roster): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
np: space after commas
|
||
try: | ||
repo = StudentRepo(host, namespace, full_name, token) | ||
repo.clone_to(os.path.join(path, username)) | ||
count += 1 | ||
repo_dir = os.path.join(path, username) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you can split here into another method without too many args... let me look:
somefunction(i + 1, repo, **student)
Am I missing something? That'll clean up the multiline variable definitions too maybe?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure it's worth it. Moving this would only make it more complicated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I'm loathe to split a function just for the sake of splitting a function.
assigner/commands/get.py
Outdated
name = student["name"] | ||
|
||
try: | ||
logging.debug("Attempting to use local repo {}...".format(repo_dir)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm starting to wonder if we should switch to logging's placeholders:
logging.debug("Attempting to use local repo \"%(local_repo)\"", local_repo=repo_dir)
No, I don't expect you to change it. Should we open an issue or just go with format 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This has the advantage of unpacking kwargs and providing debug data more easily.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This does look pretty nice...let me do that at least here.
assigner/commands/get.py
Outdated
for result in results: | ||
logging.debug("fetch result: {} {} {}".format(result.ref.name, result.flags, result.note)) | ||
|
||
if result.flags & result.NEW_HEAD: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤢
I'm surprised and upset that this is the way to do this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's what you get for using a library that doesn't wrap git tightly enough!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will document this though.
assigner/commands/get.py
Outdated
|
||
if result.flags & result.NEW_HEAD: | ||
output.add_row([row, sec, sid, name, "{}: new branch at {}".format( | ||
result.ref.name, str(result.ref.commit)[0:8] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
np 9000: str(result.ref.commit)[:8]
assigner/tqdm.py
Outdated
yield orig_out_err[0] | ||
# Relay exceptions | ||
except Exception as exc: | ||
raise exc |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Woah, this isn't the default?
TOO AWESOME 💥
assigner/tqdm.py
Outdated
|
||
def tqdm_enumerate(iterable, stdout): | ||
return enumerate(_tqdm(iterable, file=stdout, dynamic_ncols=True)) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
two spaces between top level definitions.
assigner/tqdm.py
Outdated
_tqdm.write(x, file=self.file) | ||
|
||
def flush(self): | ||
return getattr(self.file, "flush", lambda: None)() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
😵 😵 😵 😵 😵 😵
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Send documentation 🚑
assigner/commands/get.py
Outdated
)]) | ||
row = sec = sid = name = "" | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
np: too many spaces. I'd accept a space and a comment :)
assigner/tqdm.py
Outdated
"""Dummy file-like that will write to tqdm""" | ||
file = None | ||
def __init__(self, file): | ||
self.file = file |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I recognize that there are three files here but they're all named the same thing. Can we rename them?
297b16b
to
600e388
Compare
@@ -170,6 +170,25 @@ def already_exists(self): | |||
return True | |||
return False | |||
|
|||
def get_head(self, branch): | |||
if self.repo is None: | |||
raise RepoError("No repo to get head from") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we do punctuation on errors?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not that I can see, although we haven't really made a standard for that.
assigner/commands/get.py
Outdated
logging.warn(" (use --force to overwrite)") | ||
|
||
# Check out first branch specified; this is probably what people expect | ||
if len(branch) > 1: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about branches == 1? Am I missing something.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If there's just one branch, then it'll be the last thing checked out by the for loop above.
assigner/commands/get.py
Outdated
username = student["username"] | ||
student_section = student["section"] | ||
full_name = StudentRepo.name(semester, student_section, | ||
hw_name, username) | ||
hw_name, username) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
continuation should follow the opening brace, + 1 space.
f3268be
to
9d93bfd
Compare
assigner/commands/get.py
Outdated
logging.debug("Local repo exists, fetching...") | ||
results = repo.repo.remote().fetch() | ||
for result in results: | ||
logging.debug("fetch result: name: %s flags: %s note: %s", result.ref.name, result.flags, result.note) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
too long or is char limit set at 120?
399e0aa
to
fb158e4
Compare
Also, switch to
tqdm
for progress reporting...not sure I'm happy with it though.Closes #11.