otac0n / WebGitNet

WebGit .NET is an ASP.NET MVC app that provides access to your git repositories over HTTP. It supports browsing in a web browser AND push / pull over Git's "Smart HTTP protocol".
zlib License
133 stars 62 forks source link

Submodule support #52

Closed dlech closed 11 years ago

dlech commented 11 years ago

I have been using WebGitNet for a while. Thanks for your work!

I noticed that repositories with submodules cannot be displayed. I have started working on a fix. I would like to get your feedback before I get too far along.

Here is a screenshot of the changes I made. Basically, it just adds the hash to identify this as a submodule rather than a folder regular folder. It would be nice to add some styling to set it apart even more (suggestions?).

Capture

Also, submodules are not completely browsable yet - just the first level. Again if you have any suggestion on a good way to do this, I will give it a try.

otac0n commented 11 years ago

This is looking pretty nice. Thanks! I was actually planning on adding submodule support this weekend, thanks for getting the jump on it.

We should add icons to the tree view to differentiate everything (except a submodule should just look like a folder plus a commit hash). I'll take a look at adding those tonight.

Thanks again!

otac0n commented 11 years ago

So, I tried this out, using fuel/fuel as my real world example. Aside from having issues with their branch naming scheme (I had to push a fake 'master' branch), I was unable to view submodules.

My preference would be to NOT browse submodules (since this won't work for BARE repos), but instead link to the parent repository at that commit if possible. (We could auto-detect our own remote URLs and GitHub's, to start.)

That is, in order to merge this in, I'd like to see the submodules just show up as a link to the correct repository, if it can be inferred, or just have it show the URL of the "origin" remote, otherwise.

dlech commented 11 years ago

It is still a bit crude, but I have the links working as you suggested. Basically, it depends on a .submodules file being present. The information is read from there and cached. Then the ObjectTree checks to see if there is a matching commit in the tree and if there is, it uses the url that was cached. I am linking to the tree view so that you get the exact commit.

otac0n commented 11 years ago

There are still a couple issues with this, but the biggest issue is line-endings. In your second commit, the whole .csproj file shows up as changed.

To mitigate this, I have rebased your commits onto master, where I have added a .gitattributes to fix line-ending issues going forward.

I have pushed to a branch named submodule-support in my repo. Would you mind resetting your submodule_support branch to point to the same commit? You will have to do a git reset to point your branch to that commit, then a git push -f to push it. That should update this pull request.

Secondly, the links to GitHub seem to be broken, because the .git at the end of the URL needs to be trimmed off. I would fix this myself, but I need to take a look at a few other bugs today.

dlech commented 11 years ago

Sorry about the line endings. That's annoying, I know.

Fixed dropping the '.git'. I am sure that there are plenty more what-ifs that I haven't thought of.

otac0n commented 11 years ago

OK, well, I have merged this in (kinda).

I apparently screwed up the rebase when I was fixing line endings, so I amended that, cherry picked your new commit and merged it all into master.

We should be good, but you'll probably want to delete your branch.