Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Allow administrative modification of the default branch/tag referenced by HEAD #5
This allows control over the default branch after clone, which is equivalent to running:
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.
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)
"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!