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
Allow administrative modification of the default branch/tag referenced by HEAD #5
Conversation
…d by HEAD. This allows control over the default branch after clone, which is equivalent to running: git symbolic-ref HEAD refs/heads/mybranch
Revised update results which are considered successful and improved error messaging.
edited for < and > entities This looks like a useful feature. I have some comments and questions for you. Since gitblit refers to heads as branches I would change verbage from "head" to "branch". I believe this to be consistent with GitHub, etc. RepositoryModel. Because the RepositoryModel is used for federation and JSON-RPC calls I do not want List<RefModel>, it is too heavy. We could do a List<String>, though. I see in your second commit that you are using the Ref object for dealing with tags. We can still get the tag's objectid from the name, but I am wondering why I would ever want to set HEAD to a tag? Especially since you are not making a distinction between an annotated tag and a tag? My first reaction is to not include tags in the list of available branches at all. Can you point me to an example of where/why this functionality is wanted? EditRepositoryPage. I would not restrict the access to the default branch combobox. Repository Owners should be allowed to change this and only an owner or an admin can access this page anyway. EditRepositoryPage/JGitUtils.setDefaultHead. You rely on RefModel.reference which is a transient variable. It is transient because it is not serializable and Wicket demands that any model object be serializable. Wicket can and will serialize pages to disk and deserialize them as needed so we need to be careful here because the reference may be null. This is another reason why List<String>, while primitive, would be better. Gitblit.updateRepositoryModel. Maybe setDefaultHead should only be called if it has changed. I'm uncomfortable relinking HEAD on every model update. |
RepositoryModel use of RefModel (and use in setDefaultHead) Gitblit.updateRepositoryModel EditRepositoryPage permissions "head" vs. "branch" and use of a tag as symbolic HEAD ref |
Ok lets do this: Switch from RefModel to full name strings. Keep the tags, now that I understand the use it makes sense. I will probably change the dropdown renderer to differentiate between branches and tags and I may add a pop-up prompt to confirm relinking to a tag. In the updateModel method make sure to disregard null or empty defaultHead values (there is a StringUtils method for this). Models can also be updated via RPC or federation both of which may be from older versions and thus have null or empty default heads. Lets also leave your "head" labeling as it does make more sense but lets follow the Git convention of uppercase here so all methods and labels, etc should say HEAD. I have an immediate use for this relinking capability so your timing is excellent! |
…rent symbolic head and available heads. Added convenience methods to JGitUtils to support retrieving available heads as List<String>. When resolving the symbolic head target as a String, if the head is detached, attempt to match the commit SHA1 against the known tags, using the most recent tag if more than one matches. Revised error messaging to better reflect actual outcome. Adjusted tab indexes on edit repository page to include default head combo box. Updated message key for default head combo box to use uppercase "HEAD".
I've revised the code per your recommended changes. |
Allow administrative modification of the default branch/tag referenced by HEAD
Thanks Phil, this looks great. |
This allows control over the default branch after clone, which is equivalent to running:
git symbolic-ref HEAD refs/heads/mybranch
This is for use in environments where the "master" branch does not exist or should not be the default upon clone, but administrators do not want to access the GitBlit via shell and run Git commands against the bare repository.
I haven't written any unit tests for the changes to JGitUtils, but it "worked for me" in my ad hoc testing.
I didn't add a tab stop for the new form field on the "edit repository" HTML template; the indexes will need to be adjusted as part of the merge.