Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
...
Checking mergeability… Don't worry, you can still create the pull request.
  • 6 commits
  • 24 files changed
  • 1 commit comment
  • 1 contributor
Showing with 396 additions and 147 deletions.
  1. +3 −3 GitAspx.Tests/InfoRefsControllerTests.cs
  2. +3 −3 GitAspx.Tests/RpcControllerTests.cs
  3. +2 −2 GitAspx/AssemblyInfo.cs
  4. +15 −4 GitAspx/Content/Site.css
  5. +15 −10 GitAspx/Controllers/DirectoryListController.cs
  6. +18 −13 GitAspx/Controllers/DumbController.cs
  7. +9 −9 GitAspx/Controllers/InfoRefsController.cs
  8. +43 −0 GitAspx/Controllers/RepositoryController.cs
  9. +8 −7 GitAspx/Controllers/RpcController.cs
  10. +43 −0 GitAspx/Controllers/TeamListController.cs
  11. +13 −1 GitAspx/GitAspx.csproj
  12. +16 −16 GitAspx/Global.asax.cs
  13. +7 −6 GitAspx/Helpers.cs
  14. +6 −1 GitAspx/Lib/NotFoundResult.cs
  15. +18 −16 GitAspx/Lib/Repository.cs
  16. +19 −11 GitAspx/Lib/RepositoryService.cs
  17. +55 −0 GitAspx/ViewModels/CommitInfoViewModel.cs
  18. +3 −2 GitAspx/ViewModels/DirectoryListViewModel.cs
  19. +15 −23 GitAspx/ViewModels/RepositoryViewModel.cs
  20. +11 −0 GitAspx/ViewModels/TeamListViewModel.cs
  21. +11 −19 GitAspx/Views/DirectoryList/Index.cshtml
  22. +44 −0 GitAspx/Views/Repository/Index.cshtml
  23. +1 −1  GitAspx/Views/Shared/_Layout.cshtml
  24. +18 −0 GitAspx/Views/TeamList/Index.cshtml
View
6 GitAspx.Tests/InfoRefsControllerTests.cs
@@ -36,7 +36,7 @@ public class InfoRefsControllerTests {
[Test]
public void Gets_upload_pack_advertisement() {
- controller.Execute("test.git", "git-upload-pack");
+ controller.Execute("test", "test.git", "git-upload-pack");
controller.Response.ContentType.ShouldContain("application/x-git-upload-pack-advertisement");
var body = controller.Response.OutputStream.GetString();
@@ -49,7 +49,7 @@ public class InfoRefsControllerTests {
[Test]
public void Gets_receive_pack_advertisement() {
- controller.Execute("test.git", "git-receive-pack");
+ controller.Execute("test", "test.git", "git-receive-pack");
controller.Response.ContentType
.ShouldContain("application/x-git-receive-pack-advertisement");
@@ -65,7 +65,7 @@ public class InfoRefsControllerTests {
[Test]
public void Returns_404_when_repository_not_found() {
- var result = controller.Execute("NoSuchProject", "git-receive-pack");
+ var result = controller.Execute("NoSuchTeam", "NoSuchProject", "git-receive-pack");
result.ShouldBe<NotFoundResult>();
}
}
View
6 GitAspx.Tests/RpcControllerTests.cs
@@ -18,20 +18,20 @@ public class RpcControllerTests {
[Test]
public void NoAccess_to_UploadPack_when_incorrect_content_type() {
- var result = controller.UploadPack("test.git");
+ var result = controller.UploadPack("test", "test.git");
result.ShouldBe<ForbiddenResult>();
}
[Test]
public void NoAccess_to_ReceivePack_when_incorrect_content_type() {
- var result = controller.ReceivePack("test.git");
+ var result = controller.ReceivePack("test", "test.git");
result.ShouldBe<ForbiddenResult>();
}
[Test]
public void Not_found_when_wrong_path() {
controller.Request.ContentType = "application/x-git-receive-pack-request";
- var result = controller.ReceivePack("no-such-project");
+ var result = controller.ReceivePack("test", "no-such-project");
result.ShouldBe<NotFoundResult>();
}
View
4 GitAspx/AssemblyInfo.cs
@@ -4,9 +4,9 @@
[assembly: AssemblyTitle("GitAspx")]
[assembly: AssemblyDescription("ASP.NET Implementation of git-http-backend")]
-[assembly: AssemblyCompany("Jeremy Skinner")]
+[assembly: AssemblyCompany("PMoney")]
[assembly: AssemblyProduct("GitAspx")]
-[assembly: AssemblyCopyright("Copyright © Jeremy Skinner 2010")]
+[assembly: AssemblyCopyright("Copyright © PMoney 2012")]
[assembly: ComVisible(false)]
[assembly: Guid("087abc38-5949-4dbe-9549-9be40bc57cc3")]
[assembly: AssemblyVersion("0.3.0.0")]
View
19 GitAspx/Content/Site.css
@@ -5,6 +5,19 @@ body {
font-size:11px;
}
+.commit-author {
+ color: royalblue;
+}
+.commit-hash {
+ color: gray;float: left; width: 6em;height: 100%;border: thin solid transparent;
+}
+.commit-date {
+ color: gray;white-space: nowrap;
+}
+.commit-message {
+ font-size: 75%;
+}
+
.clear {
clear:both;
font-size:0.1px;
@@ -53,20 +66,18 @@ ul#repositories li {
ul#repositories li a {
font-size:13px;
color:#000;
- height:15px;
width:auto;
padding:5px 5px 5px 20px;
margin:5px 0 5px 5px;
text-decoration:none;
- display:block;
- overflow:hidden;
+ display: block;
background:#cbd6de url(images/bullet.png) no-repeat 0 40%;
-webkit-border-radius: 3px;
-moz-border-radius: 3px;
border-radius: 3px;
}
-ul#repositories li a:hover {
+ul#repositories li a.repository:hover {
background-color:#fff;
}
View
25 GitAspx/Controllers/DirectoryListController.cs
@@ -19,31 +19,36 @@
#endregion
namespace GitAspx.Controllers {
- using System.Web.Mvc;
+ using System.IO;
+ using System.Web.Mvc;
using GitAspx.Lib;
using GitAspx.ViewModels;
using System.Linq;
+ using GitSharp.Core.Exceptions;
- public class DirectoryListController : Controller {
+ public class DirectoryListController : Controller {
readonly RepositoryService repositories;
public DirectoryListController(RepositoryService repositories) {
this.repositories = repositories;
}
- public ActionResult Index() {
- return View(new DirectoryListViewModel {
- RepositoriesDirectory = repositories.GetRepositoriesDirectory().FullName,
- Repositories = repositories.GetAllRepositories().Select(x => new RepositoryViewModel(x))
+ public ActionResult Index(string team) {
+ var teamDirectory = repositories.GetRepositoriesDirectory(team);
+ if (teamDirectory == null) return new NotFoundResult("Team");
+ return View(new DirectoryListViewModel {
+ RepositoriesDirectory = teamDirectory,
+ Repositories = repositories.GetAllRepositories(team).Select(x => new RepositoryViewModel(x))
});
}
[HttpPost]
- public ActionResult Create(string project) {
- if (!string.IsNullOrEmpty(project)) {
- repositories.CreateRepository(project);
+ public ActionResult Create(string directory, string project) {
+ if (!string.IsNullOrEmpty(project) && !string.IsNullOrEmpty(directory))
+ {
+ repositories.CreateRepository(directory, project);
}
- return RedirectToAction("Index");
+ return Redirect("/" + Path.GetFileName(directory));
}
}
}
View
31 GitAspx/Controllers/DumbController.cs
@@ -13,35 +13,40 @@ public class DumbController : BaseController {
this.repositories = repositories;
}
- public ActionResult GetTextFile(string project) {
- return WriteFile(project, "text/plain");
+ public ActionResult GetTextFile(string team, string project)
+ {
+ return WriteFile(team, project, "text/plain");
}
- public ActionResult GetInfoPacks(string project) {
- return WriteFile(project, "text/plain; charset=utf-8");
+ public ActionResult GetInfoPacks(string team, string project)
+ {
+ return WriteFile(team, project, "text/plain; charset=utf-8");
}
- public ActionResult GetLooseObject(string project) {
- return WriteFile(project, "application/x-git-loose-object");
+ public ActionResult GetLooseObject(string team, string project)
+ {
+ return WriteFile(team, project, "application/x-git-loose-object");
}
- public ActionResult GetPackFile(string project) {
- return WriteFile(project, "application/x-git-packed-objects");
+ public ActionResult GetPackFile(string team, string project)
+ {
+ return WriteFile(team, project, "application/x-git-packed-objects");
}
- public ActionResult GetIdxFile(string project) {
- return WriteFile(project, "application/x-git-packed-objects-toc");
+ public ActionResult GetIdxFile(string team, string project)
+ {
+ return WriteFile(team, project, "application/x-git-packed-objects-toc");
}
- private ActionResult WriteFile(string project, string contentType) {
+ private ActionResult WriteFile(string team, string project, string contentType) {
Response.WriteNoCache();
Response.ContentType = contentType;
- var repo = repositories.GetRepository(project);
+ var repo = repositories.GetRepository(team, project);
string path = Path.Combine(repo.GitDirectory(), GetPathToRead(project));
if(! System.IO.File.Exists(path)) {
- return new NotFoundResult();
+ return new NotFoundResult(string.Format("{0}/{1}", team, project));
}
Response.WriteFile(path);
View
18 GitAspx/Controllers/InfoRefsController.cs
@@ -34,20 +34,20 @@ public class InfoRefsController : BaseController {
this.repositories = repositories;
}
- public ActionResult Execute(string project, string service) {
+ public ActionResult Execute(string team, string project, string service) {
service = GetServiceType(service);
bool isUsingSmartProtocol = service != null;
// Service has been specified - we're working with the smart protocol
if(isUsingSmartProtocol) {
- return SmartInfoRefs(service, project);
+ return SmartInfoRefs(service, team, project);
}
// working with the dumb protocol.
- return DumbInfoRefs(project);
+ return DumbInfoRefs(team, project);
}
- ActionResult SmartInfoRefs(string service, string project) {
+ ActionResult SmartInfoRefs(string service, string team, string project) {
Response.ContentType = "application/x-git-{0}-advertisement".With(service);
Response.WriteNoCache();
@@ -56,10 +56,10 @@ public class InfoRefsController : BaseController {
// If we don't set it, then it defaults to utf-8, which breaks jgit's logic for detecting smart http
Response.Charset = "";
- var repository = repositories.GetRepository(project);
+ var repository = repositories.GetRepository(team, project);
if (repository == null) {
- return new NotFoundResult();
+ return new NotFoundResult(string.Format("{0}/{1}", team, project));
}
Response.PktWrite("# service=git-{0}\n", service);
@@ -76,14 +76,14 @@ public class InfoRefsController : BaseController {
return new EmptyResult();
}
- ActionResult DumbInfoRefs(string project) {
+ ActionResult DumbInfoRefs(string team, string project) {
Response.WriteNoCache();
Response.ContentType = "text/plain; charset=utf-8";
- var repository = repositories.GetRepository(project);
+ var repository = repositories.GetRepository(team, project);
if(repository == null) {
- return new NotFoundResult();
+ return new NotFoundResult(string.Format("{0}/{1}", team, project));
}
repository.UpdateServerInfo();
View
43 GitAspx/Controllers/RepositoryController.cs
@@ -0,0 +1,43 @@
+#region License
+
+// Copyright 2010 Jeremy Skinner (http://www.jeremyskinner.co.uk)
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+// The latest version of this file can be found at http://github.com/JeremySkinner/git-dot-aspx
+
+#endregion
+
+namespace GitAspx.Controllers {
+ using System.IO;
+ using System.Web.Mvc;
+ using GitAspx.Lib;
+ using GitAspx.ViewModels;
+ using System.Linq;
+
+ public class RepositoryController : Controller {
+ readonly RepositoryService repositories;
+
+ public RepositoryController(RepositoryService repositories)
+ {
+ this.repositories = repositories;
+ }
+
+ public ActionResult Index(string team, string project) {
+ var repo = repositories.GetRepository(team, project);
+ ViewBag.Team = team;
+ ViewBag.Project = project;
+ return View(new RepositoryViewModel(repo));
+ }
+ }
+}
View
15 GitAspx/Controllers/RpcController.cs
@@ -36,15 +36,16 @@ public class RpcController : BaseController {
}
[HttpPost]
- public ActionResult UploadPack(string project) {
- return ExecuteRpc(project, "upload-pack", repository => {
+ public ActionResult UploadPack(string team, string project)
+ {
+ return ExecuteRpc(team, project, "upload-pack", repository => {
repository.Upload(GetInputStream(), Response.OutputStream);
});
}
[HttpPost]
- public ActionResult ReceivePack(string project) {
- return ExecuteRpc(project, "receive-pack", repository => {
+ public ActionResult ReceivePack(string team, string project) {
+ return ExecuteRpc(team, project, "receive-pack", repository => {
repository.Receive(GetInputStream(), Response.OutputStream);
});
}
@@ -56,7 +57,7 @@ public class RpcController : BaseController {
return Request.InputStream;
}
- ActionResult ExecuteRpc(string project, string rpc, Action<Repository> action) {
+ ActionResult ExecuteRpc(string team, string project, string rpc, Action<Repository> action) {
if (!HasAccess(rpc, checkContentType: true)) {
return new ForbiddenResult();
}
@@ -64,10 +65,10 @@ public class RpcController : BaseController {
Response.ContentType = "application/x-git-{0}-result".With(rpc);
Response.WriteNoCache();
- var repository = repositories.GetRepository(project);
+ var repository = repositories.GetRepository(team, project);
if (repository == null) {
- return new NotFoundResult();
+ return new NotFoundResult(string.Format("{0}/{1}", team, project));
}
action(repository);
View
43 GitAspx/Controllers/TeamListController.cs
@@ -0,0 +1,43 @@
+#region License
+
+// Copyright 2010 Jeremy Skinner (http://www.jeremyskinner.co.uk)
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+// The latest version of this file can be found at http://github.com/JeremySkinner/git-dot-aspx
+
+#endregion
+
+namespace GitAspx.Controllers {
+ using System.IO;
+ using System.Web.Mvc;
+ using GitAspx.Lib;
+ using GitAspx.ViewModels;
+ using System.Linq;
+
+ public class TeamListController : Controller {
+ readonly RepositoryService repositories;
+
+ public TeamListController(RepositoryService repositories)
+ {
+ this.repositories = repositories;
+ }
+
+ public ActionResult Index() {
+ return View(new TeamListViewModel {
+ RepositoriesDirectory = repositories.GetRootDirectory().FullName,
+ Directories = repositories.GetRootDirectory().GetDirectories()
+ });
+ }
+ }
+}
View
14 GitAspx/GitAspx.csproj
@@ -84,6 +84,8 @@
<ItemGroup>
<Compile Include="Constants.cs" />
<Compile Include="Controllers\BaseController.cs" />
+ <Compile Include="Controllers\RepositoryController.cs" />
+ <Compile Include="Controllers\TeamListController.cs" />
<Compile Include="Controllers\DirectoryListController.cs" />
<Compile Include="Controllers\DumbController.cs" />
<Compile Include="Controllers\InfoRefsController.cs" />
@@ -100,6 +102,8 @@
<Compile Include="Lib\StructureMapControllerFactory.cs" />
<Compile Include="AssemblyInfo.cs" />
<Compile Include="Lib\RepositoryService.cs" />
+ <Compile Include="ViewModels\CommitInfoViewModel.cs" />
+ <Compile Include="ViewModels\TeamListViewModel.cs" />
<Compile Include="ViewModels\DirectoryListViewModel.cs" />
<Compile Include="ViewModels\RepositoryViewModel.cs" />
</ItemGroup>
@@ -111,7 +115,9 @@
<Content Include="Content\Site.css" />
<Content Include="Global.asax" />
<Content Include="Scripts\jquery.modal.js" />
- <Content Include="Web.config" />
+ <Content Include="Web.config">
+ <SubType>Designer</SubType>
+ </Content>
<Content Include="Views\Web.config">
<SubType>Designer</SubType>
</Content>
@@ -160,6 +166,12 @@
<ItemGroup>
<Content Include="Views\Shared\_Layout.cshtml" />
</ItemGroup>
+ <ItemGroup>
+ <Content Include="Views\TeamList\Index.cshtml" />
+ </ItemGroup>
+ <ItemGroup>
+ <Content Include="Views\Repository\Index.cshtml" />
+ </ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
View
32 GitAspx/Global.asax.cs
@@ -31,42 +31,42 @@ public class MvcApplication : HttpApplication {
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.IgnoreRoute("favicon.ico");
- routes.MapRoute("DirectoryList", "", new {controller = "DirectoryList", action = "Index"});
- routes.MapRoute("DirectoryListCreate", "Create", new { controller = "DirectoryList", action = "Create" });
+ routes.MapRoute("TeamList", "", new { controller = "TeamList", action = "Index" });
+ routes.MapRoute("DirectoryListCreate", "Create", new { controller = "DirectoryList", action = "Create" });
+ routes.MapRoute("DirectoryList", "{team}", new { controller = "DirectoryList", action = "Index" });
- routes.MapRoute("info-refs", "{project}/info/refs",
+ routes.MapRoute("info-refs", "{team}/{project}/info/refs",
new {controller = "InfoRefs", action = "Execute"},
new {method = new HttpMethodConstraint("GET")});
- routes.MapRoute("upload-pack", "{project}/git-upload-pack",
+ routes.MapRoute("upload-pack", "{team}/{project}/git-upload-pack",
new {controller = "Rpc", action = "UploadPack"},
new {method = new HttpMethodConstraint("POST")});
- routes.MapRoute("receive-pack", "{project}/git-receive-pack",
+ routes.MapRoute("receive-pack", "{team}/{project}/git-receive-pack",
new {controller = "Rpc", action = "ReceivePack"},
new {method = new HttpMethodConstraint("POST")});
// Dumb protocol
- //routes.MapRoute("info-refs-dumb", "dumb/{project}/info/refs", new {controller = "Dumb", action = "InfoRefs"});
- routes.MapRoute("get-text-file", "{project}/HEAD", new{controller = "Dumb", action="GetTextFile" });
- routes.MapRoute("get-text-file2", "{project}/objects/info/alternates", new { controller = "Dumb", action = "GetTextFile" });
- routes.MapRoute("get-text-file3", "{project}/objects/info/http-alternates", new { controller = "Dumb", action = "GetTextFile" });
+ routes.MapRoute("get-text-file", "{team}/{project}/HEAD", new { controller = "Dumb", action = "GetTextFile" });
+ routes.MapRoute("get-text-file2", "{team}/{project}/objects/info/alternates", new { controller = "Dumb", action = "GetTextFile" });
+ routes.MapRoute("get-text-file3", "{team}/{project}/objects/info/http-alternates", new { controller = "Dumb", action = "GetTextFile" });
- routes.MapRoute("get-info-packs", "{project}/info/packs", new {controller = "Dumb", action = "GetInfoPacks"});
+ routes.MapRoute("get-info-packs", "{team}/{project}/info/packs", new { controller = "Dumb", action = "GetInfoPacks" });
- routes.MapRoute("get-text-file4", "{project}/objects/info/{something}", new {controller = "Dumb", action = "GetTextFile"});
+ routes.MapRoute("get-text-file4", "{team}/{project}/objects/info/{something}", new { controller = "Dumb", action = "GetTextFile" });
- routes.MapRoute("get-loose-object", "{project}/objects/{segment1}/{segment2}",
+ routes.MapRoute("get-loose-object", "{team}/{project}/objects/{segment1}/{segment2}",
new {controller = "Dumb", action = "GetLooseObject"});
- routes.MapRoute("get-pack-file", "{project}/objects/pack/pack-{filename}.pack",
+ routes.MapRoute("get-pack-file", "{team}/{project}/objects/pack/pack-{filename}.pack",
new { controller = "Dumb", action = "GetPackFile" });
-
- routes.MapRoute("get-idx-file", "{project}/objects/pack/pack-{filename}.idx",
+
+ routes.MapRoute("get-idx-file", "{team}/{project}/objects/pack/pack-{filename}.idx",
new {controller = "Dumb", action = "GetIdxFile"});
- routes.MapRoute("project", "{project}");
+ routes.MapRoute("project", "{team}/{project}", new { controller = "Repository", action="Index"});
}
protected void Application_Start() {
View
13 GitAspx/Helpers.cs
@@ -36,11 +36,12 @@ public static class Helpers {
get { return version;}
}
- public static string ProjectUrl(this UrlHelper urlHelper, string project) {
- return urlHelper.RouteUrl("project", new RouteValueDictionary(new {project}),
- urlHelper.RequestContext.HttpContext.Request.Url.Scheme,
- urlHelper.RequestContext.HttpContext.Request.Url.Host);
- }
+ public static string ProjectUrl(this UrlHelper urlHelper, string team, string project)
+ {
+ return urlHelper.RouteUrl("project", new RouteValueDictionary(new { team, project }),
+ urlHelper.RequestContext.HttpContext.Request.Url.Scheme,
+ urlHelper.RequestContext.HttpContext.Request.Url.Host);
+ }
public static string ToPrettyDateString(this DateTime d) {
TimeSpan s = DateTime.Now.Subtract(d);
@@ -70,7 +71,7 @@ public static class Helpers {
if (dayDiff == 1)
return "yesterday";
- if (dayDiff < 7)
+ if (dayDiff <= 7)
return string.Format("{0} days ago", dayDiff);
if (dayDiff < 31)
View
7 GitAspx/Lib/NotFoundResult.cs
@@ -22,10 +22,15 @@ namespace GitAspx.Lib {
using System.Web.Mvc;
public class NotFoundResult : ActionResult {
+ private readonly string thing;
+ public NotFoundResult(string thing) {
+ this.thing = thing;
+ }
+
public override void ExecuteResult(ControllerContext context) {
context.HttpContext.Response.StatusCode = 404;
context.HttpContext.Response.ContentType = "text/plain";
- context.HttpContext.Response.Write("Not Found");
+ context.HttpContext.Response.Write(string.Format("{0} Not Found", this.thing));
}
}
}
View
34 GitAspx/Lib/Repository.cs
@@ -8,7 +8,7 @@ namespace GitAspx.Lib {
using GitSharp.Core.Transport;
public class Repository {
- private DirectoryInfo directory;
+ private readonly DirectoryInfo directory;
public static Repository Open(DirectoryInfo directory) {
if (GitSharp.Repository.IsValid(directory.FullName)) {
@@ -53,18 +53,24 @@ public class Repository {
}
}
- public CommitInfo GetLatestCommit() {
+ public IEnumerable<GitSharp.Commit> GetRecentCommits(int number) {
+ using (var repository = new GitSharp.Repository(FullPath)) {
+ var commit = repository.CurrentBranch.CurrentCommit;
+ if (commit == null) return null;
+ var recentCommits = new List<GitSharp.Commit> { commit };
+ for (var i = 0; i < number; ++i) {
+ commit = commit.Parent;
+ if (commit == null) break;
+ recentCommits.Add(commit);
+ }
+ return recentCommits;
+ }
+ }
+
+ public GitSharp.Commit GetLatestCommit()
+ {
using (var repository = new GitSharp.Repository(FullPath)) {
- var commit = repository.Head.CurrentCommit;
-
- if (commit == null) {
- return null;
- }
-
- return new CommitInfo {
- Message = commit.Message,
- Date = commit.CommitDate.DateTime
- };
+ return repository.Head.CurrentCommit;
}
}
@@ -131,8 +137,4 @@ public class Repository {
}
}
- public class CommitInfo {
- public string Message { get; set; }
- public DateTime Date { get; set; }
- }
}
View
30 GitAspx/Lib/RepositoryService.cs
@@ -30,16 +30,20 @@ public class RepositoryService {
this.appSettings = appSettings;
}
- public IEnumerable<Repository> GetAllRepositories() {
- return appSettings.RepositoriesDirectory
+ public DirectoryInfo GetRootDirectory() {
+ return appSettings.RepositoriesDirectory;
+ }
+
+ public IEnumerable<Repository> GetAllRepositories(string team) {
+ return GetRepositoriesDirectory(team)
.GetDirectories()
.Select(Repository.Open)
.Where(x => x!=null)
.ToList();
}
- public Repository GetRepository(string project) {
- var directory = Path.Combine(appSettings.RepositoriesDirectory.FullName, project);
+ public Repository GetRepository(string team, string project) {
+ var directory = Path.Combine(appSettings.RepositoriesDirectory.FullName, team, project);
if (!Directory.Exists(directory)) {
return null;
@@ -49,17 +53,21 @@ public class RepositoryService {
return new Repository(new DirectoryInfo(directory));
}
- public DirectoryInfo GetRepositoriesDirectory() {
- return appSettings.RepositoriesDirectory;
+ public DirectoryInfo GetRepositoriesDirectory(string team)
+ {
+ return appSettings.RepositoriesDirectory.GetDirectories(team).FirstOrDefault();
}
- public void CreateRepository(string project) {
- var directory = Path.Combine(appSettings.RepositoriesDirectory.FullName, project + ".git");
+ public void CreateRepository(string directory, string project)
+ {
+ var repositoryDirectory = Path.Combine(directory, project + ".git");
- if (!Directory.Exists(directory)) {
- Directory.CreateDirectory(directory);
+ if (!Directory.Exists(repositoryDirectory))
+ {
+ Directory.CreateDirectory(repositoryDirectory);
- using(var repository = new GitSharp.Core.Repository(new DirectoryInfo(directory))) {
+ using (var repository = new GitSharp.Core.Repository(new DirectoryInfo(repositoryDirectory)))
+ {
repository.Create(true);
}
}
View
55 GitAspx/ViewModels/CommitInfoViewModel.cs
@@ -0,0 +1,55 @@
+#region License
+
+// Copyright 2010 Jeremy Skinner (http://www.jeremyskinner.co.uk)
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+// The latest version of this file can be found at http://github.com/JeremySkinner/git-dot-aspx
+
+#endregion
+
+namespace GitAspx.ViewModels {
+ using System.Collections.Generic;
+ using System.IO;
+ using GitAspx.Lib;
+ using GitSharp;
+
+ public class CommitInfoViewModel
+ {
+ private readonly Commit commit;
+
+ public CommitInfoViewModel(Commit commit)
+ {
+ this.commit = commit;
+ }
+
+ public string Message
+ {
+ get { return commit.Message; }
+ }
+
+ public string Hash {
+ get { return commit.ShortHash; }
+ }
+
+ public string Author {
+ get {
+ return commit.Author.Name;
+ }
+ }
+
+ public string Date {
+ get { return commit.CommitDate.DateTime.ToPrettyDateString(); }
+ }
+ }
+}
View
5 GitAspx/ViewModels/DirectoryListViewModel.cs
@@ -23,8 +23,9 @@ namespace GitAspx.ViewModels {
using System.IO;
using GitAspx.Lib;
- public class DirectoryListViewModel {
- public string RepositoriesDirectory { get; set; }
+ public class DirectoryListViewModel
+ {
+ public DirectoryInfo RepositoriesDirectory { get; set; }
public IEnumerable<RepositoryViewModel> Repositories { get; set; }
}
}
View
38 GitAspx/ViewModels/RepositoryViewModel.cs
@@ -1,41 +1,33 @@
namespace GitAspx.ViewModels {
using System;
+ using System.Collections.Generic;
+ using System.Linq;
using GitAspx.Lib;
public class RepositoryViewModel {
- private Repository repository;
- private CommitInfo latestCommit;
+ private readonly Repository repository;
public RepositoryViewModel(Repository repository) {
this.repository = repository;
- this.latestCommit = repository.GetLatestCommit();
}
public string Name {
get { return repository.Name; }
}
- private string CommitDate {
- get { return latestCommit != null ? latestCommit.Date.ToPrettyDateString() : string.Empty; }
- }
-
- private string Message {
- get {
- if(latestCommit != null) {
- string message = latestCommit.Message;
+ public CommitInfoViewModel LatestCommit {
+ get {
+ var latestCommit = repository.GetLatestCommit();
+ return latestCommit == null ? null : new CommitInfoViewModel(latestCommit);
+ }
+ }
- if(message.Length > 60) {
- return message.Substring(0, 57) + "...";
- }
+ public IEnumerable<CommitInfoViewModel> RecentCommits {
+ get {
+ var latestCommit = repository.GetLatestCommit();
+ return latestCommit == null ? null : repository.GetRecentCommits(10).Select(commitInfo => new CommitInfoViewModel(commitInfo));
+ }
+ }
- return message;
- }
- return string.Empty;
- }
- }
-
- public string LatestCommitInfo {
- get {return Message + " - " + CommitDate; }
- }
}
}
View
11 GitAspx/ViewModels/TeamListViewModel.cs
@@ -0,0 +1,11 @@
+
+namespace GitAspx.ViewModels {
+ using System.Collections.Generic;
+ using System.IO;
+ using GitAspx.Lib;
+
+ public class TeamListViewModel {
+ public string RepositoriesDirectory { get; set; }
+ public IEnumerable<DirectoryInfo> Directories { get; set; }
+ }
+}
View
30 GitAspx/Views/DirectoryList/Index.cshtml
@@ -5,17 +5,21 @@
}
<div class="repositoryContainer">
- <h1>@Model.RepositoriesDirectory</h1>
+ <h1>Repositories for @Model.RepositoriesDirectory.Name</h1>
- <a href="javascript:void(0)" class="createRepository">Create a new bare repository</a>
+ <a href="javascript:void(0)" class="createRepository">Create a new repository</a>
<div class="clear"></div>
<ul id="repositories">
@foreach (var repository in Model.Repositories) {
<li>
- <a class="repository" href="javascript:void(0)" title="@Url.ProjectUrl(repository.Name)">
- @repository.Name
- <span class="latest-commit">@repository.LatestCommitInfo</span>
+ <a class="repository" href="@Model.RepositoriesDirectory/@repository.Name" title="@Url.ProjectUrl(Model.RepositoriesDirectory.Name, repository.Name)">
+ <strong>@repository.Name</strong>
+ @if (repository.LatestCommit != null) {
+ <span>
+ <span class="commit-author">@repository.LatestCommit.Author</span>: <span class="commit-message">@repository.LatestCommit.Message</span> - <span class="commit-date">@repository.LatestCommit.Date</span>
+ </span>
+ }
</a>
</li>
}
@@ -34,6 +38,7 @@
<div class="title">Create a new repository <a href="#" class="jqmClose"><img src="@Url.Content("~/Content/images/close.png")" alt="Close" /></a></div>
<div class="content">
@using (Html.BeginForm("Create", "DirectoryList")) {
+ <input type="hidden" name="directory" value="@Model.RepositoriesDirectory.FullName" />
<input type="text" name="project" />@:.git<br />
<input type="submit" value="Create a new repository" class="button" />
}
@@ -42,23 +47,10 @@
<script type="text/javascript">
$(function () {
- $('#dialog').jqm();
$('#createRepositoryDialog').jqm();
- $('#repository-url').click(function () {
- $(this).select();
- });
-
- $('a.repository').click(function () {
- var url = $(this).attr('title');
- $('#dialog').jqmShow();
- $('#repository-url').val(url).focus().select();
- });
-
$('a.createRepository').click(function () {
$('#createRepositoryDialog').jqmShow();
});
});
-</script>
-
-</asp:Content>
+</script>
View
44 GitAspx/Views/Repository/Index.cshtml
@@ -0,0 +1,44 @@
+@using GitAspx.ViewModels
+@using GitAspx;
+@model RepositoryViewModel
+
+@{
+ ViewBag.Title = "Commits";
+ string team = ViewBag.Team;
+ string project = ViewBag.Project;
+}
+
+<div class="repositoryContainer">
+ <h1>Recent commits for <a class="repository" href="javascript:void(0)" title="@Url.ProjectUrl(team, project)">@Model.Name</a></h1>
+
+ <ul id="repositories">
+ @if (Model.LatestCommit != null) {
+ foreach (var commit in Model.RecentCommits) {
+ <li><a><span class="commit-hash">@commit.Hash</span> <span class="commit-author">@commit.Author</span>: <span class="commit-message">@commit.Message</span> - <span class="commit-date">@commit.Date</span></a></li>
+ }
+ }
+ else {
+ <p>No commits.</p>
+ }
+ </ul>
+</div>
+
+<div class="jqmWindow" id="dialog">
+ <div class="title">Clone the repository using this command <a href="#" class="jqmClose"><img src="@Url.Content("~/Content/images/close.png")" alt="Close" /></a></div>
+ <div class="content">
+ <pre>git clone <input type="text" id="repository-url" /></pre>
+ </div>
+</div>
+
+<script>
+ $('#dialog').jqm();
+ $('#repository-url').click(function () {
+ $(this).select();
+ });
+
+ $('a.repository').click(function () {
+ var url = $(this).attr('title');
+ $('#dialog').jqmShow();
+ $('#repository-url').val(url).focus().select();
+ });
+</script>
View
2  GitAspx/Views/Shared/_Layout.cshtml
@@ -14,7 +14,7 @@
@RenderBody()
<div id="footer">
- <a href="http://github.com/JeremySkinner/git-dot-aspx">Powered by GitAspx @Helpers.Version</a>
+ <a href="http://github.com/pranavraja/git-dot-aspx">Powered by GitAspx @Helpers.Version</a>
</div>
</div>
</body>
View
18 GitAspx/Views/TeamList/Index.cshtml
@@ -0,0 +1,18 @@
+@using GitAspx.ViewModels
+@using GitAspx
+@model TeamListViewModel
+
+<div class="repositoryContainer">
+ <h1>Teams</h1>
+
+ <ul id="repositories">
+ @foreach (var directory in Model.Directories) {
+ <li>
+ <a class="repository" href="/@directory.Name" title="@directory.Name">
+ <strong>@directory.Name</strong>
+ </a>
+ </li>
+ }
+ </ul>
+
+</div>

Showing you all comments on commits in this comparison.

@linquize

Good! You changed to team / project hierarchy.
I did something similar in my fork.
The original fork gives us the base of the project (clone, upload, receive, create).
Although the original author is inactive, I think development for GitAspx can be continued.

Something went wrong with that request. Please try again.