Skip to content

Commit

Permalink
Initial port commit
Browse files Browse the repository at this point in the history
  • Loading branch information
latop2604 committed Dec 6, 2017
1 parent 811b704 commit f306e8c
Show file tree
Hide file tree
Showing 729 changed files with 55,978 additions and 3,417 deletions.
18 changes: 10 additions & 8 deletions Bonobo.Git.Server.sln
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.25420.1
# Visual Studio 15
VisualStudioVersion = 15.0.27004.2009
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Bonobo.Git.Server", "Bonobo.Git.Server\Bonobo.Git.Server.csproj", "{6129B3FE-B282-4F6F-8836-8AF66602F8DA}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Bonobo.Git.Server", "Bonobo.Git.Server\Bonobo.Git.Server.csproj", "{6129B3FE-B282-4F6F-8836-8AF66602F8DA}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Bonobo.Git.Server.Test", "Bonobo.Git.Server.Test\Bonobo.Git.Server.Test.csproj", "{0B124D88-5C2B-47AD-B660-434B709A0DFF}"
EndProject
Expand All @@ -30,11 +30,12 @@ Global
{6129B3FE-B282-4F6F-8836-8AF66602F8DA}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{6129B3FE-B282-4F6F-8836-8AF66602F8DA}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{6129B3FE-B282-4F6F-8836-8AF66602F8DA}.Release|x86.ActiveCfg = Release|Any CPU
{6129B3FE-B282-4F6F-8836-8AF66602F8DA}.Test|Any CPU.ActiveCfg = Test|Any CPU
{6129B3FE-B282-4F6F-8836-8AF66602F8DA}.Test|Any CPU.Build.0 = Test|Any CPU
{6129B3FE-B282-4F6F-8836-8AF66602F8DA}.Test|Mixed Platforms.ActiveCfg = Test|Any CPU
{6129B3FE-B282-4F6F-8836-8AF66602F8DA}.Test|Mixed Platforms.Build.0 = Test|Any CPU
{6129B3FE-B282-4F6F-8836-8AF66602F8DA}.Test|x86.ActiveCfg = Test|Any CPU
{6129B3FE-B282-4F6F-8836-8AF66602F8DA}.Test|Any CPU.ActiveCfg = Release|Any CPU
{6129B3FE-B282-4F6F-8836-8AF66602F8DA}.Test|Any CPU.Build.0 = Release|Any CPU
{6129B3FE-B282-4F6F-8836-8AF66602F8DA}.Test|Mixed Platforms.ActiveCfg = Release|Any CPU
{6129B3FE-B282-4F6F-8836-8AF66602F8DA}.Test|Mixed Platforms.Build.0 = Release|Any CPU
{6129B3FE-B282-4F6F-8836-8AF66602F8DA}.Test|x86.ActiveCfg = Release|Any CPU
{6129B3FE-B282-4F6F-8836-8AF66602F8DA}.Test|x86.Build.0 = Release|Any CPU
{0B124D88-5C2B-47AD-B660-434B709A0DFF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{0B124D88-5C2B-47AD-B660-434B709A0DFF}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0B124D88-5C2B-47AD-B660-434B709A0DFF}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
Expand All @@ -55,6 +56,7 @@ Global
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {451ECF4B-DC19-4E9A-9D02-DA13796309D7}
EnterpriseLibraryConfigurationToolBinariesPath = packages\Unity.2.1.505.2\lib\NET35
EndGlobalSection
EndGlobal
4 changes: 2 additions & 2 deletions Bonobo.Git.Server/.bowerrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"directory" : "Content/components"
}
"directory": "wwwroot/lib"
}
1 change: 0 additions & 1 deletion Bonobo.Git.Server/App_Data/Repositories/note.txt

This file was deleted.

12 changes: 0 additions & 12 deletions Bonobo.Git.Server/App_Data/Web.config

This file was deleted.

Empty file.
2 changes: 1 addition & 1 deletion Bonobo.Git.Server/App_GlobalResources/Resources.resx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Expand Down
25 changes: 0 additions & 25 deletions Bonobo.Git.Server/App_Start/BundleConfig.cs

This file was deleted.

206 changes: 102 additions & 104 deletions Bonobo.Git.Server/App_Start/RouteConfig.cs
Original file line number Diff line number Diff line change
@@ -1,104 +1,102 @@
using System;
using System.Web.Mvc;
using System.Web.Routing;

namespace Bonobo.Git.Server.App_Start
{
public class RouteConfig
{
public static void RegisterRoutes(RouteCollection routes)
{
routes.MapRoute("SecureInfoRefs",
"{repositoryName}.git/info/refs",
new { controller = "Git", action = "SecureGetInfoRefs" },
new { method = new HttpMethodConstraint("GET") });

routes.MapRoute("SecureUploadPack",
"{repositoryName}.git/git-upload-pack",
new { controller = "Git", action = "SecureUploadPack" },
new { method = new HttpMethodConstraint("POST") });

routes.MapRoute("SecureReceivePack",
"{repositoryName}.git/git-receive-pack",
new { controller = "Git", action = "SecureReceivePack" },
new { method = new HttpMethodConstraint("POST") });

routes.MapRoute("GitBaseUrl",
"{repositoryName}.git",
new { controller = "Git", action = "GitUrl" },
new { method = new HttpMethodConstraint("GET") });

routes.MapRoute("IndexRoute",
"{controller}/Index/",
new { action = "Index" });

routes.MapRoute("CreateRoute",
"{controller}/Create/",
new { action = "Create" });

routes.MapRoute("RepositoryTree",
"Repository/{id}/{encodedName}/Tree/{*encodedPath}",
new { controller = "Repository", action = "Tree" });

routes.MapRoute("RepositoryBlob",
"Repository/{id}/{encodedName}/Blob/{*encodedPath}",
new { controller = "Repository", action = "Blob" },
new { id = @"\d+" });

routes.MapRoute("RepositoryRaw",
"Repository/{id}/{encodedName}/Raw/{*encodedPath}",
new { controller = "Repository", action = "Raw" });

routes.MapRoute("RepositoryBlame",
"Repository/{id}/{encodedName}/Blame/{*encodedPath}",
new { controller = "Repository", action = "Blame" });

routes.MapRoute("RepositoryDownload",
"Repository/{id}/{encodedName}/Download/{*encodedPath}",
new { controller = "Repository", action = "Download" });

routes.MapRoute("RepositoryCommits",
"Repository/{id}/{encodedName}/Commits",
new { controller = "Repository", action = "Commits" });

routes.MapRoute("RepositoryCommit",
"Repository/{id}/{encodedName}/Commit/{commit}/",
new { controller = "Repository", action = "Commit" });

routes.MapRoute("RepositoryHistory",
"Repository/{id}/{encodedName}/History/{*encodedPath}",
new { controller = "Repository", action = "History" },
new { id = @"\d+" });

routes.MapRoute("Repository",
"Repository/{id}/{action}/{reponame}",
new { controller = "Repository", action = "Detail", reponame = UrlParameter.Optional },
new { id = @"\d+" });

routes.MapRoute("Account",
"Account/{id}/{action}/{username}",
new { controller = "Account", action = "Detail", username = UrlParameter.Optional },
new { id = @"\d+" });

routes.MapRoute("Team",
"Team/{id}/{action}/{teamname}",
new { controller = "Team", action = "Detail", teamname = UrlParameter.Optional },
new { id = @"\d+" });


routes.MapRoute("Validation", "Validation/{action}", new { controller = "Validation", action = String.Empty });

routes.MapRoute("RepoCommits",
"Repository/Commits/{id}",
new { controller = "Repository", action = "Commits", id = string.Empty});

routes.MapRoute("Default",
"{controller}/{action}/{id}",
new { controller = "Home", action = "Index", id = String.Empty });

routes.IgnoreRoute("{*favicon}", new { favicon = @"(.*/)?favicon.ico(/.*)?" });

routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
}
}
}
//using System;

//namespace Bonobo.Git.Server.App_Start
//{
// public class RouteConfig
// {
// public static void RegisterRoutes(RouteCollection routes)
// {
// //routes.MapRoute("SecureInfoRefs",
// // "{repositoryName}.git/info/refs",
// // new { controller = "Git", action = "SecureGetInfoRefs" },
// // new { method = new HttpMethodConstraint("GET") });

// //routes.MapRoute("SecureUploadPack",
// // "{repositoryName}.git/git-upload-pack",
// // new { controller = "Git", action = "SecureUploadPack" },
// // new { method = new HttpMethodConstraint("POST") });

// //routes.MapRoute("SecureReceivePack",
// // "{repositoryName}.git/git-receive-pack",
// // new { controller = "Git", action = "SecureReceivePack" },
// // new { method = new HttpMethodConstraint("POST") });

// //routes.MapRoute("GitBaseUrl",
// // "{repositoryName}.git",
// // new { controller = "Git", action = "GitUrl" },
// // new { method = new HttpMethodConstraint("GET") });

// routes.MapRoute("IndexRoute",
// "{controller}/Index/",
// new { action = "Index" });

// routes.MapRoute("CreateRoute",
// "{controller}/Create/",
// new { action = "Create" });

// routes.MapRoute("RepositoryTree",
// "Repository/{id}/{encodedName}/Tree/{*encodedPath}",
// new { controller = "Repository", action = "Tree" });

// routes.MapRoute("RepositoryBlob",
// "Repository/{id}/{encodedName}/Blob/{*encodedPath}",
// new { controller = "Repository", action = "Blob" },
// new { id = @"\d+" });

// routes.MapRoute("RepositoryRaw",
// "Repository/{id}/{encodedName}/Raw/{*encodedPath}",
// new { controller = "Repository", action = "Raw" });

// routes.MapRoute("RepositoryBlame",
// "Repository/{id}/{encodedName}/Blame/{*encodedPath}",
// new { controller = "Repository", action = "Blame" });

// routes.MapRoute("RepositoryDownload",
// "Repository/{id}/{encodedName}/Download/{*encodedPath}",
// new { controller = "Repository", action = "Download" });

// routes.MapRoute("RepositoryCommits",
// "Repository/{id}/{encodedName}/Commits",
// new { controller = "Repository", action = "Commits" });

// routes.MapRoute("RepositoryCommit",
// "Repository/{id}/{encodedName}/Commit/{commit}/",
// new { controller = "Repository", action = "Commit" });

// routes.MapRoute("RepositoryHistory",
// "Repository/{id}/{encodedName}/History/{*encodedPath}",
// new { controller = "Repository", action = "History" },
// new { id = @"\d+" });

// routes.MapRoute("Repository",
// "Repository/{id}/{action}/{reponame}",
// new { controller = "Repository", action = "Detail", reponame = UrlParameter.Optional },
// new { id = @"\d+" });

// routes.MapRoute("Account",
// "Account/{id}/{action}/{username}",
// new { controller = "Account", action = "Detail", username = UrlParameter.Optional },
// new { id = @"\d+" });

// routes.MapRoute("Team",
// "Team/{id}/{action}/{teamname}",
// new { controller = "Team", action = "Detail", teamname = UrlParameter.Optional },
// new { id = @"\d+" });


// routes.MapRoute("Validation", "Validation/{action}", new { controller = "Validation", action = String.Empty });

// routes.MapRoute("RepoCommits",
// "Repository/Commits/{id}",
// new { controller = "Repository", action = "Commits", id = string.Empty });

// routes.MapRoute("Default",
// "{controller}/{action}/{id}",
// new { controller = "Home", action = "Index", id = String.Empty });

// routes.IgnoreRoute("{*favicon}", new { favicon = @"(.*/)?favicon.ico(/.*)?" });

// routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
// }
// }
//}
39 changes: 22 additions & 17 deletions Bonobo.Git.Server/Attributes/AllViewsAttribute.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
using Bonobo.Git.Server.App_GlobalResources;
using Bonobo.Git.Server.Models;
using Bonobo.Git.Server.Security;
using Microsoft.Practices.Unity;
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web.Mvc;
using Bonobo.Git.Server.App_GlobalResources;
using Bonobo.Git.Server.Models;
using Bonobo.Git.Server.Security;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Filters;
using Microsoft.AspNetCore.Mvc.Rendering;
using Microsoft.AspNetCore.Mvc.Routing;
using Microsoft.Extensions.DependencyInjection;

namespace Bonobo.Git.Server.Attributes
{
Expand Down Expand Up @@ -33,29 +36,31 @@ public int GetHashCode(T obj)

public class AllViewsFilter : ActionFilterAttribute
{
[Dependency]
public IRepositoryPermissionService RepoPermissions { get; set; }

public override void OnActionExecuting(ActionExecutingContext filterContext)
{
filterContext.Controller.ViewBag.PermittedRepositories = PopulateRepoGoToList(filterContext.HttpContext.User.Id(), filterContext.Controller.ControllerContext);
if (filterContext.Controller is Controller ctrl)
{
ctrl.ViewBag.PermittedRepositories = PopulateRepoGoToList(filterContext, filterContext.HttpContext.User.Id());
}
}

private List<SelectListItem> PopulateRepoGoToList(Guid id, ControllerContext ControllerContext)
private List<SelectListItem> PopulateRepoGoToList(ActionExecutingContext filterContext, Guid id)
{
var pullList = RepoPermissions.GetAllPermittedRepositories(id, RepositoryAccessLevel.Pull);
var adminList = RepoPermissions.GetAllPermittedRepositories(id, RepositoryAccessLevel.Administer);
var repoPermissions = filterContext.HttpContext.RequestServices.GetService<IRepositoryPermissionService>();

var pullList = repoPermissions.GetAllPermittedRepositories(id, RepositoryAccessLevel.Pull);
var adminList = repoPermissions.GetAllPermittedRepositories(id, RepositoryAccessLevel.Administer);
var firstList = pullList.Union(adminList, new InlineComparer<RepositoryModel>((lhs, rhs) => lhs.Id == rhs.Id, obj => obj.Id.GetHashCode()))
.OrderBy(x => x.Name.ToLowerInvariant())
.GroupBy(x => x.Group == null ? Resources.Repository_No_Group : x.Group);
.GroupBy(x => x.Group ?? Resources.Repository_No_Group);

List<SelectListItem> items = new List<SelectListItem>();
var u = new UrlHelper(ControllerContext.RequestContext);
var u = new UrlHelper(filterContext);
var groups = new Dictionary<string, SelectListGroup>();
foreach (var grouped in firstList)
{
SelectListGroup group = null;
string key = grouped.Key;
if (!groups.TryGetValue(key, out group))
if (!groups.TryGetValue(key, out SelectListGroup group))
{
group = new SelectListGroup();
group.Name = key;
Expand Down
12 changes: 4 additions & 8 deletions Bonobo.Git.Server/Attributes/EmailAttribute.cs
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations;

namespace Bonobo.Git.Server
{
public class EmailAttribute : RegularExpressionAttribute
{
{
public EmailAttribute() :
base(@"^(([A-Za-z0-9]+_+)|([A-Za-z0-9]+\-+)|([A-Za-z0-9]+\.+)|([A-Za-z0-9]+\++))*[A-Za-z0-9]+@((\w+\-+)|(\w+\.))*\w{1,63}\.[a-zA-Z]{2,63}$")
{
base(@"^(([A-Za-z0-9]+_+)|([A-Za-z0-9]+\-+)|([A-Za-z0-9]+\.+)|([A-Za-z0-9]+\++))*[A-Za-z0-9]+@((\w+\-+)|(\w+\.))*\w{1,63}\.[a-zA-Z]{2,63}$")
{
}
}
}
Loading

0 comments on commit f306e8c

Please sign in to comment.