Project

General

Profile

Actions

Feature #1406

closed

Browse through Git branches

Added by James Turnbull almost 16 years ago. Updated over 14 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
SCM
Target version:
Start date:
2008-06-09
Due date:
% Done:

100%

Estimated time:
Resolution:

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

branch_support.diff (53.8 KB) branch_support.diff Adam Soltys, 2009-07-01 21:24
branch_support.diff (76.2 KB) branch_support.diff Adam Soltys, 2009-07-27 08:55
branch_support.diff (76.3 KB) branch_support.diff Adam Soltys, 2009-08-07 07:43
git_adapter.rb.diff (3.3 KB) git_adapter.rb.diff Fix Git commands who list branches and tags to be more Windows friendly and checking if last revision is correctly formatted Babar O'Cap, 2009-08-11 10:20
submodules.png (136 KB) submodules.png Jiongliang Zhang, 2009-08-25 10:04

Related issues

Related to Redmine - Defect #3515: Sensible Git repository branchesClosed2009-06-19

Actions
Related to Redmine - Defect #7984: Confusing revisions links on repository rootNewToshi MARUYAMA2011-03-24

Actions
Related to Redmine - Feature #7246: Handle "named branch" for mercurialClosedToshi MARUYAMA2011-01-07

Actions
Related to Redmine - Defect #8458: Subversion: Delete invalid repository fails using the libsvn pluginClosedToshi MARUYAMA2011-05-29

Actions
Related to Redmine - Defect #4725: Error displaying Project's Settings when repository configuredNew2010-02-03

Actions
Related to Redmine - Defect #6713: Git: Not able to Resetting Redmine project respositoryNewToshi MARUYAMA2010-10-20

Actions
Related to Redmine - Defect #4547: git: Very high CPU usage for a long time with large repositoryClosed2010-01-11

Actions
Related to Redmine - Defect #4716: Git repository performance fall on parsing new commits after 0.9.1 updateClosed2010-02-02

Actions
Has duplicate Redmine - Feature #1387: Support git branches and tags in repository browser/activity/issue associationsClosed2008-06-05

Actions
Has duplicate Redmine - Defect #3138: Only one branch is shown for GitClosed2009-04-08

Actions
Actions #1

Updated by David Marín Carreño almost 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).

Actions #2

Updated by Ask Bjørn Hansen almost 16 years ago

FWIW, we are also missing this functionality.

Actions #3

Updated by Matthew W over 15 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...

Actions #4

Updated by David Bronke about 15 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.

Actions #5

Updated by Jérémie Delaitre about 15 years ago

And of course, Mercurial branches support would be great too !

Actions #6

Updated by Babar O'Cap about 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

Actions #7

Updated by James Turnbull about 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.

Actions #8

Updated by Kiall Mac Innes almost 15 years ago

+1 For this - This is really an essential feature for anyone using redmine+git!

Actions #9

Updated by Sergey Avseyev almost 15 years ago

+1

Actions #10

Updated by Andrew Shcheglov almost 15 years ago

+1

Actions #11

Updated by Daniel Svensson almost 15 years ago

+1

Actions #12

Updated by Adam Soltys almost 15 years ago

+1

Actions #13

Updated by Adam Soltys almost 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

Actions #14

Updated by Carl-Johan Sveningsson almost 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 .

Actions #15

Updated by Jan from Planio www.plan.io almost 15 years ago

+1 thanks :)

Actions #16

Updated by Adam Soltys almost 15 years ago

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.
Known issues:
  • 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
Future plans:
Actions #17

Updated by Steve Diver almost 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.

Actions #18

Updated by Jan Losinski almost 15 years ago

I would also be happy if this patch goes upstream.

Actions #19

Updated by Eric Davis almost 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.

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.

Actions #20

Updated by Adam Soltys almost 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.

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.

Actions #21

Updated by Steve Diver almost 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.

Actions #22

Updated by Adam Soltys over 14 years ago

This latest diff should resolve the following issues:

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.

Actions #23

Updated by Adam Soltys over 14 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.

Actions #24

Updated by Eric Davis over 14 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.

Actions #25

Updated by Jiongliang Zhang over 14 years ago

+1 hope Bazaar also can.

Actions #26

Updated by Jiongliang Zhang over 14 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'
Actions #27

Updated by Jiongliang Zhang over 14 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'
Actions #28

Updated by Adam Soltys over 14 years ago

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

Actions #29

Updated by Babar O'Cap over 14 years ago

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

Actions #30

Updated by Eric Davis over 14 years ago

Reviewing this now, thanks again for the patches and testing.

Actions #31

Updated by Eric Davis over 14 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.

Actions #32

Updated by James Turnbull over 14 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...

Actions #33

Updated by Muntek Singh over 14 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.

Actions #34

Updated by Babar O'Cap over 14 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

Actions #35

Updated by Jiongliang Zhang over 14 years ago

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:

Actions #36

Updated by Jiongliang Zhang over 14 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.

Actions #37

Updated by Steve Diver over 14 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.

Actions #38

Updated by Adam Soltys over 14 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.

Actions #39

Updated by Jiongliang Zhang over 14 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.
Actions #40

Updated by Eric Davis over 14 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.

Actions #41

Updated by Jiongliang Zhang over 14 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.

Actions

Also available in: Atom PDF