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
feat: add meaningful data to auto branch names #3077
Conversation
renku/core/util/git.py
Outdated
pushed_branch = uuid4().hex | ||
user = get_git_user(repository) | ||
email = getattr(user, "email", "unknown") | ||
pushed_branch = f"{PRETECTED_BRANCH_PREFIX}/{email}/{old_active_branch}/{last_short_sha}" |
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 we should check that the branch name length does not get too long. According to https://stackoverflow.com/questions/60045157/what-is-the-maximum-length-of-a-github-branch-name it's anywhere between 60 and 250 characters. We probably want to shorten old_active_branch
down to a minimum of 6 if it's too long or so and if it's still too long, chorten the email?
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 makes sense. A shortened email might not be very useful after all. Let me check with @ciyer if dropping it would work.
I'll still add the check for the old_active_branch
just in case
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.
Then let us drop the email.
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.
Ok, I dropped the email and added the logic to limit branch names to 250 chars
Description
Change name of branches automatically generated when trying to push to a remote protected branch.
The final branch name will be
renku/autobranch/<username>/<protected_branch_name>/<commit_sha>
.The username is the email address to keep it in line with what renku notebooks does with autosaves.
P.S. I'm not 100% sure that using
get_git_user
is the best solution. I assume it's fine most of the time, but I can imagine it being potentially wrong when working on the cli. Should I instead pass the local user topush_changes
as a parameter? I don't like that solution either and, to be honest, I feel adding that user here is somewhat unnecessary (it's fine for autosaves since they contain personal content, but in general having a username/email in a branch name looks very weird).This also includes a minor fix for a service error.
Fixes #2374