Feature #1406
closedBrowse through Git branches
100%
Description
I'd like the Git SCM Adapter to support Git branches. Much like GitHub does currently allowing you to select and browse through branches (for example as you can see you can select the relevant branch at this url - http://github.com/yugui/redmine4ruby-lang/tree/master).
Additionally it'd be great if Git changes outside of the master branch were reported in Redmine and available (see #1387) in Activity, etc.
I'll take a stab at this but my Ruby-fu is hack'ish and weak. :P
Files
Related issues
Updated by David Marín Carreño over 16 years ago
Perhaps, the solution for this could be related to CVS branching and tagging support (feature #1411) (already knowing that these two SCMs are very different).
Updated by Ask Bjørn Hansen over 16 years ago
FWIW, we are also missing this functionality.
Updated by Matthew W almost 16 years ago
I too would find this very useful. Since branching is so key to git usage, it seems a bit odd to support git without branches...
Updated by David Bronke almost 16 years ago
It'd also be useful to have similar support for branches in other SCM's such as Bazaar, Darcs, and Monotone. Most of my projects use Bazaar now, and not being able to browse through anything except trunk is rather limiting.
Updated by Jérémie Delaitre almost 16 years ago
And of course, Mercurial branches support would be great too !
Updated by Babar O'Cap over 15 years ago
If you want to change(checkout) the default branch of your git repo checkout you can do :
git symbolic-ref HEAD refs/heads/mybranch
Which will update the HEAD file in your repository so that it contains:
ref: refs/heads/mybranch
source: http://feeding.cloud.geek.nz/2008/12/setting-default-git-branch-in-bare.html
Updated by James Turnbull over 15 years ago
Babar Le lapin wrote:
If you want to change(checkout) the default branch of your git repo checkout you can do :
git symbolic-ref HEAD refs/heads/mybranch
That's fine but it doesn't allow branch browsing inside Redmine which is what I am after.
Updated by Kiall Mac Innes over 15 years ago
+1 For this - This is really an essential feature for anyone using redmine+git!
Updated by Adam Soltys over 15 years ago
I'm starting to work on this. To view my progress see http://github.com/asoltys/redmine/commits/git_branch_support
There have already been a couple of attempts. For details and discussion see http://www.redmine.org/boards/2/topics/2873
Updated by Carl-Johan Sveningsson over 15 years ago
+1
Adam Ross, thanks a bunch for working on this. I understand that you're taking the grit path to get support - would you say it is functioning yet and can I easily build a new redmine with a patch for this maybe?
It's not much, but I mention some that flat commit history could be a simplistic option as well in #3515 .
Updated by Adam Soltys over 15 years ago
- File branch_support.diff branch_support.diff added
Hi guys, thanks for taking an interest. I'm attaching a .diff that should apply cleanly to the current trunk and provides preliminary support for browsing git branches. You can see it in action at http://projects.adamsoltys.com/projects/redmine/repository
I've made it so that redmine will always show a list of 'Latest revisions' as you browse through directories. The list gets filtered to only show revisions pertaining to the current directory and currently selected branch. If you click to view all revisions, it will show all commits regardless of what branch they occurred in.
Also, Redmine's Activity page will now list revisions from all branches. They should also be linked to from issues if you reference the issue number in your commit messages.
This is my first ever attempt at patching an open source project. Please let me know if you have any feedback for me. Enjoy!
Install:- Apply the attached .diff to your current installation: cd /path/to/redmine && patch -p0 -i /path/to/branch_support.diff
- Install required gems: sudo gem install diff-lcs mime-types grit
- Restart ruby server. No database migrations required.
- Assumes that branch names are alphanumeric
- Merge commits are currently ignored until I figure out how I want to handle them
- File renames are not reported properly
- Revisions dated earlier than the latest revision Redmine knows of will not be discovered if they were pushed or merged in later
- Extend branch support to other SCM's (Mercurial, Darcs, etc)
- Support tag browsing
- Support all valid branch/tag names described by http://www.kernel.org/pub/software/scm/git/docs/git-check-ref-format.html
- Improve performance. Right now Redmine will probably choke on repositories with long histories or when browsing directories with lots of files.
Updated by Steve Diver over 15 years ago
Thank you Adam for your efforts. We have been waiting with baited breath for this feature to be added for some time, and we have been putting off using full branch capabilities for our members due to the lack of tracking and browsing.
I have tested your demo, and it all looks good. We will also test the patch on a copy of our own repositories, and provide feedback where necessary. A full patch to our own installation will hopefully happen soon, and we would definitely like to see this officially enter the 0.8.5 point release if possible.
Updated by Jan Losinski over 15 years ago
I would also be happy if this patch goes upstream.
Updated by Eric Davis over 15 years ago
Thanks Adam, I see you've added tag browsing now. I'd like to review this to see about applying it to the core. Lets see if we can agree on solutions to the known issues
Known issues:
- Assumes that branch names are alphanumeric
It looks like your demo is supporting other characters also (.-). Is this still an issue?
- Merge commits are currently ignored until I figure out how I want to handle them
What if we just add a commit with the log and no changes? That looks like how GitHub is doing it and it still lets people know when merges happened.
- File renames are not reported properly
I don't think that would be a large problem as long as the changes show the old and new files.
- Revisions dated earlier than the latest revision Redmine knows of will not be discovered if they were pushed or merged in later
What if Redmine rescans the repository?
Future plans:
- Extend branch support to other SCM's (Mercurial, Darcs, etc)
It looks like you are working on a mercurial version now. Could you put that into another branch on Github so I can exclude it while pulling the git version in?
- Support tag browsing
Appears to be working on your demo.
- Support all valid branch/tag names described by http://www.kernel.org/pub/software/scm/git/docs/git-check-ref-format.html
I think this could be ongoing. Basic support is better than complete support right now and I don't know many git users who are using non standard branch names.
- Improve performance. Right now Redmine will probably choke on repositories with long histories or when browsing directories with lots of files.
That can be improved later. Ideally we can collect some performance metrics and see where the slow spots are and if it's worth it to speed up.
Steve Diver wrote:
... we would definitely like to see this officially enter the 0.8.5 point release if possible.
This is a new feature so it will probably go into 0.9. 0.8.x is for bug fixes right now.
Updated by Adam Soltys over 15 years ago
Hi Eric,
Thanks for taking preliminary look. I've been a bit busy this past week so sorry for not getting back to you right away. You've raised some really good points and I've responded to them below. In summary: I'll probably want another week or so to work on things before I ask you to review them again for possible 0.9 integration.
Thanks Adam, I see you've added tag browsing now. I'd like to review this to see about applying it to the core. Lets see if we can agree on solutions to the known issues
Known issues:
- Assumes that branch names are alphanumeric
It looks like your demo is supporting other characters also (.-). Is this still an issue?
Yep, dots and dashes are supported now. It just occurred to me though that underscores are important too. I'll allow those too!
- Merge commits are currently ignored until I figure out how I want to handle them
What if we just add a commit with the log and no changes? That looks like how GitHub is doing it and it still lets people know when merges happened.
Sure, that'll work for now. I can always get fancier with merges later.
- File renames are not reported properly
I don't think that would be a large problem as long as the changes show the old and new files.
Additions, modifications, and deletions are showing fine. I may get renames working in the next few days anyways though so I'll let you know if I do.
- Revisions dated earlier than the latest revision Redmine knows of will not be discovered if they were pushed or merged in later
What if Redmine rescans the repository?
Well, that's what I'll have to implement -- some sort of scanning/tracking algorithm that can discover untracked revisions in the repo log without having to INSERT them all. Right now Redmine just says "INSERT revisions dated later than the latest one I know about so far". I could force it to always start from the beginning but that would be prohibitively slow especially with large repos.
Future plans:
- Extend branch support to other SCM's (Mercurial, Darcs, etc)
It looks like you are working on a mercurial version now. Could you put that into another branch on Github so I can exclude it while pulling the git version in?
Ok, I'll separate the Mercurial stuff out.
- Support tag browsing
Appears to be working on your demo.
Yep, tags are available now.
- Support all valid branch/tag names described by http://www.kernel.org/pub/software/scm/git/docs/git-check-ref-format.html
I think this could be ongoing. Basic support is better than complete support right now and I don't know many git users who are using non standard branch names.
Agreed. We can patch this up later if people start raising issues because their branch names aren't supported.
- Improve performance. Right now Redmine will probably choke on repositories with long histories or when browsing directories with lots of files.
That can be improved later. Ideally we can collect some performance metrics and see where the slow spots are and if it's worth it to speed up.
Again, agreed. The biggest repo I've tried out so far is redmine itself and that wasn't too bad.
Steve Diver wrote:
... we would definitely like to see this officially enter the 0.8.5 point release if possible.
This is a new feature so it will probably go into 0.9. 0.8.x is for bug fixes right now.
Making it into 0.9 would be great! Maybe I can support all the SCM's by then. Now that I've done two, the rest should be cake. I'll do each of them in a separate branch so that they're easy to pull in one-by-one if you want to start with git.
Updated by Steve Diver over 15 years ago
Eric Davis wrote:
Steve Diver wrote:
... we would definitely like to see this officially enter the 0.8.5 point release if possible.
This is a new feature so it will probably go into 0.9. 0.8.x is for bug fixes right now.
I would contend that a "Missing feature" is a bug. To use a driving analogy, we have a car with a multispeed gearbox, but no gear stick. Repository Branch browsing does not require any database migrations either, which fits within the guidelines for point releases.
That said, I am very happy to see this considered for 0.9, and I agree with all of the points above.
Updated by Adam Soltys over 15 years ago
- File branch_support.diff branch_support.diff added
This latest diff should resolve the following issues:
- Earlier commits are now found even when they're pushed or merged in after the latest known commit
- File renames and copies are now detected
- Mercurial branch/tag support has been moved to a separate line of development (http://github.com/asoltys/redmine/commits/mercurial_branch_support)
At this point I'm pretty happy with where the patch is at and don't plan to do much more work on it unless other people find problems with it. I've been periodically pulling in changes from the trunk so it should apply cleanly to r2825.
Updated by Adam Soltys over 15 years ago
Oh, and I forgot to mention, the patch no longer depends on the grit, diff-lcs and mime-types gems, so there is no need to install them anymore.
Updated by Eric Davis over 15 years ago
- Status changed from New to 7
- Assignee set to Eric Davis
Adam said it's pretty much done and ready for a review.
Updated by Jiongliang Zhang over 15 years ago
the patch get an error, when point to any path not git repository or the path not exist.
branch_support.diff (76.2 KB) Adam Soltys, 2009-07-27 14:55
Processing RepositoriesController#show (for 172.25.78.92 at 2009-07-29 14:51:59) [GET] Parameters: {"action"=>"show", "id"=>"redmine-2825", "controller"=>"repositories"} NoMethodError (undefined method `map' for nil:NilClass): /app/models/repository/git.rb:66:in `fetch_changesets' /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/associations/association_proxy.rb:214:in `send' /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/associations/association_proxy.rb:214:in `method_missing' /app/controllers/repositories_controller.rb:68:in `show' /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/base.rb:1253:in `send' /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/base.rb:1253:in `perform_action_without_filters' /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/filters.rb:617:in `call_filters' /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/filters.rb:610:in `perform_action_without_benchmark' /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/benchmarking.rb:68:in `perform_action_without_rescue' /usr/local/lib/ruby/1.8/benchmark.rb:293:in `measure' /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/benchmarking.rb:68:in `perform_action_without_rescue' /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/rescue.rb:136:in `perform_action_without_caching' /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/caching/sql_cache.rb:13:in `perform_action' /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/connection_adapters/abstract/query_cache.rb:34:in `cache' /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/query_cache.rb:8:in `cache' /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/caching/sql_cache.rb:12:in `perform_action' /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/base.rb:524:in `send' /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/base.rb:524:in `process_without_filters' /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/filters.rb:606:in `process_without_session_management_support' /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/session_management.rb:134:in `process' /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/base.rb:392:in `process' /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/dispatcher.rb:183:in `handle_request' /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/dispatcher.rb:110:in `dispatch_unlocked' /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/dispatcher.rb:123:in `dispatch'
Updated by Jiongliang Zhang over 15 years ago
an error again, when branch name is "app", see: branch name "my_branch" is ok, but branch name is "app" is not ok.
Processing RepositoriesController#show (for 172.25.78.92 at 2009-08-03 12:36:49) [GET] Parameters: {"rev"=>"my_branch", "action"=>"show", "id"=>"redmine-2825", "controller"=>"repositories", "path"=>[]} Rendering template within layouts/base Rendering repositories/show Completed in 270ms (View: 126, DB: 17) | 200 OK [http://172.25.78.117/projects/redmine-2825/repository/show?rev=my_branch] Processing RepositoriesController#show (for 172.25.78.92 at 2009-08-03 12:36:53) [GET] Parameters: {"rev"=>"app", "action"=>"show", "id"=>"redmine-2825", "controller"=>"repositories", "path"=>[]} NoMethodError (undefined method `map!' for nil:NilClass): /app/models/repository/git.rb:80:in `latest_changesets' /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/associations/association_proxy.rb:214:in `send' /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/associations/association_proxy.rb:214:in `method_missi ng' /app/controllers/repositories_controller.rb:75:in `show' /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/base.rb:1253:in `send' /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/base.rb:1253:in `perform_action_without_filters' /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/filters.rb:617:in `call_filters' /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/filters.rb:610:in `perform_action_without_benchmark' /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/benchmarking.rb:68:in `perform_action_without_rescue ' /usr/local/lib/ruby/1.8/benchmark.rb:293:in `measure'
Updated by Adam Soltys over 15 years ago
- File branch_support.diff branch_support.diff added
Thanks jiongliang, I've coded in some checks that should prevent these crashes from occurring. The diff has been updated to reflect this and should now apply to r2835
Updated by Babar O'Cap over 15 years ago
- File git_adapter.rb.diff git_adapter.rb.diff added
Adam > Your patch is cool! Thanks for your work. But it's doesn't work well on Windows (tested only with Jurby 1.3.1).
Here a patch of your patch ;)
Updated by Eric Davis over 15 years ago
Reviewing this now, thanks again for the patches and testing.
Updated by Eric Davis over 15 years ago
- Status changed from 7 to Closed
- Target version set to 0.9.0
- % Done changed from 0 to 100
Committed Adam Soltys patch/branch with a few minor changes in r2840. This is a pretty big change so I'd like to get some more feedback and bug reports on how it's working in the wild. I tested it with a few repositories and didn't run into any errors but there might be some edge cases that come up. Just open new bug reports for anything you find and I'll try to fix them.
Updated by James Turnbull over 15 years ago
As the originator of this feature request - thanks to all who contributed over its long life. Whilst I'll miss #1406 very much it had a long and happy life and its child, r2840, looks to live on for a long, long time in its new home in Redmine Trunk.
Thanks to Eric, Adam, and Babar for your code and all the many others who +1'ed this feature...
Updated by Muntek Singh over 15 years ago
First off, OMG AWESOME THANK YOU
Second:
01:02:45 < Khalsa> edavis10: if I have a repo with only one branch, it still shows an empty choice in the drop down, once selected, appends the url with /show?rev= but then goes back to main branch
Statistics aren't per-branch, but tbh don't really care :)
Otherwise we have noticed no issues yet, maybe in several hours when the power users start waking up.
Updated by Babar O'Cap over 15 years ago
Just for information if you use Git and Redmine on Windows :
Adding
;%GIT_PATH%\cmd;%GIT_PATH%\bin;to your PATH environment variable.
Where GIT_PATH is the install directory of Git (eg: C:\Git)
Maybe it'll be fine to add this tip on RedmineRepositories
Updated by Jiongliang Zhang about 15 years ago
- File submodules.png submodules.png added
Thanks Adam Soltys support the good patch, but there's another problem I found. like:
/ |-- a ==> git repository | `-- a.txt |-- b ==> git repository | `-- b.txt |-- c ==> git repository | `-- c.txt |-- d ==> git repository | `-- d.txt `-- super |-- d ==> git submodule ==> git submodule base on repository "d" | |-- d.txt | `-- super.txt `-- src |-- a ==> git submodule base on repository "a" |-- b ==> git submodule base on repository "b" `-- c ==> git submodule base on repository "c"
then, I set the path of repository like: /super/.git
Problem is: It just make submodule as file and no files in it at all.
see:
Updated by Jiongliang Zhang about 15 years ago
can show the branch revisions like this:
* 89a52f4 merge app to master |\ | * e759371 app 3. | * 51ba009 app 2. | * 0b1cc1b app 1. * | e06a434 master 3. * | 27c7085 master 2. * | ea1474d master 1. |/ * 03c0f81 message14 * 6bdb714 message3 * dd60532 message2 * 278ce47 message1 * 87f8f6c submodule a
I think it will more usefull for users.
Updated by Steve Diver about 15 years ago
Submodules are an important feature of Git, but should not be confused with branches. I would like to see submodule support too, but believe this to be a separate issue and should be treated as such due to the different mechanisms involved.
Maybe Adam Soltys, Eric Davies and the others would consider lending support for this powerful feature?
Congratulations and thanks for the 0.9 inclusion of Branch tracking.
Updated by Adam Soltys about 15 years ago
Thanks for pointing that out jiongliang, I'll try to address the submodule issue by at least displaying a different icon in the tree to indicate that it's a submodule folder and not a file. I'd have to think a bit more about whether we should actually try to make submodules browsable and whether it makes sense to include their revision history within the main repository history. Of course if we support git submodules, we should also support SVN externals which are similar, and I'm guessing other SCM's have equivalent constructs. There is already an open issue for this: #1948
I also like the idea of graphically showing the branch lines and merge points, something akin to the "gitk" tool or the network graph view that github provides (e.g. http://github.com/edavis10/redmine/network) but I'm not sure this is within my ability/availability right now.
Another of my main priorities is to extend the branch/tag browsing support to all the other SCMs that redmine supports if it makes sense for them. I plan to start work on that in the coming weeks/months.
Updated by Jiongliang Zhang about 15 years ago
1. Error: The entry does not exist or can not be annotated, it happens at many files. And the files have so Chinese words, does it because unicode or something?
But I really sure its exist.
Parameters: {"rev"=>"master", "action"=>"annotate", "id"=>"scm-test", "controller"=>"repositories", "path"=>["source", "engine", "engine", "engine.c"]} Rendering template within layouts/base Completed in 89ms (View: 15, DB: 9) | 500 Internal Server Error [http://172.25.78.117/projects/scm-test/repository/revisions/master/annotate/source/engine/engine/engine.c]2. Operation steps:
- 1. when I rename a directory "src" to "source" (git), no edit any files.
- 2. generate a commit object "ddddddd"(git),
- 3. press "Repository" (redmine),
- 4. press "ddddddd" revision,(redmine), but it shows the working tree fiels, like: files.txt
- 5. press "file.txt" link, then
- 6. error happen: The entry or revision was not found in the repository.
Updated by Eric Davis about 15 years ago
jiongliang zhang:
Could you open new Feature requests or Bug reports for your issues? The original scope for this issue is complete and I don't want to lose your suggestions. Thanks.
Updated by Jiongliang Zhang about 15 years ago
Eric Davis wrote:
jiongliang zhang:
Could you open new Feature requests or Bug reports for your issues? The original scope for this issue is complete and I don't want to lose your suggestions. Thanks.
Remove to #3832, thank you for your advice.