Skip to content
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

Merged
merged 4 commits into from
Jan 17, 2018

Conversation

LinuxMercedes
Copy link
Member

Also, switch to tqdm for progress reporting...not sure I'm happy with it though.

Closes #11.

@LinuxMercedes
Copy link
Member Author

@brhoades I re-did the progress bar method; this is a bit less bad I think?


progress = tqdm()

for i,student in progress.enumerate(roster):
Copy link
Member

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)
Copy link
Member

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?

Copy link
Member

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.

Copy link
Member Author

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.

name = student["name"]

try:
logging.debug("Attempting to use local repo {}...".format(repo_dir))
Copy link
Member

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 🤔

Copy link
Member

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.

Copy link
Member Author

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.

for result in results:
logging.debug("fetch result: {} {} {}".format(result.ref.name, result.flags, result.note))

if result.flags & result.NEW_HEAD:
Copy link
Member

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?

Copy link
Member Author

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!

Copy link
Member Author

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.


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]
Copy link
Member

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
Copy link
Member

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))

Copy link
Member

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)()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😵 😵 😵 😵 😵 😵

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Send documentation 🚑

)])
row = sec = sid = name = ""


Copy link
Member

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
Copy link
Member

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?

@@ -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")
Copy link
Member

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?

Copy link
Member Author

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.

logging.warn(" (use --force to overwrite)")

# Check out first branch specified; this is probably what people expect
if len(branch) > 1:
Copy link
Member

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.

Copy link
Member Author

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.

username = student["username"]
student_section = student["section"]
full_name = StudentRepo.name(semester, student_section,
hw_name, username)
hw_name, username)
Copy link
Member

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.

@LinuxMercedes LinuxMercedes force-pushed the do-git-pull branch 2 times, most recently from f3268be to 9d93bfd Compare January 16, 2018 20:03
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)
Copy link
Member

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants