Skip to content

Commit

Permalink
Style Fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
otac0n committed May 3, 2013
1 parent fc76601 commit 00353f6
Show file tree
Hide file tree
Showing 16 changed files with 58 additions and 95 deletions.
3 changes: 0 additions & 3 deletions WebGitNet.SharedLib/GitErrorException.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@
namespace WebGitNet
{
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

public class GitErrorException : Exception
{
Expand Down
2 changes: 0 additions & 2 deletions WebGitNet.SharedLib/GitRef.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ namespace WebGitNet
{
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

public enum RefType
{
Expand Down
103 changes: 52 additions & 51 deletions WebGitNet.SharedLib/GitUtilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ namespace WebGitNet
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Web;
using System.Web.Configuration;
using StackExchange.Profiling;
using System.Web;

public static class GitUtilities
{
Expand Down Expand Up @@ -190,7 +190,7 @@ public static RepoInfo GetRepoInfo(string repoPath)
File.Exists(Path.Combine(repoPath, "HEAD")))
);

var isRepoBare =
var isRepoBare =
isRepo &&
(!Directory.Exists(Path.Combine(repoPath, ".git")));

Expand Down Expand Up @@ -621,7 +621,7 @@ public static TreeView GetTreeInfo(string repoPath, string tree, string path = n
{
var gitmodules = Execute(string.Format("show {0}:{1}.gitmodules", Q(tree), Q(path)), repoPath, Encoding.UTF8, trustErrorCode: true);
submodules = GetSubmoduleUrls(gitmodules);
}
}
catch
{
// .gitmodules file does not exist
Expand All @@ -633,7 +633,8 @@ public static TreeView GetTreeInfo(string repoPath, string tree, string path = n
private static IDictionary<string, SubmoduleInfo> GetSubmoduleUrls(string gitmodules)
{
var submoduleList = new Dictionary<string, SubmoduleInfo>();
if (gitmodules != null) {
if (gitmodules != null)
{
using (var reader = new StringReader(gitmodules))
{
Regex headerRegex = new Regex(@"\[(.*)\s""(.*)""\]");
Expand All @@ -646,58 +647,58 @@ private static IDictionary<string, SubmoduleInfo> GetSubmoduleUrls(string gitmod
{
try
{
var submodule = match.Groups[2].Value;
var items = new Dictionary<string, string>();
line = reader.ReadLine();
while (line != null && (match = itemsRegex.Match(line)).Groups.Count == 3)
{
string key = match.Groups[1].Value;
string value = match.Groups[2].Value;
// parse url to make is useable
if (key == "url")
{
// scp-like syntax is valid for git, but does not conform to uri standards
// so we need to fix it up
Regex scpLikeRegex = new Regex(@"\w*@.*:(\d*).*");
if ((match = scpLikeRegex.Match(value)).Groups.Count > 1 && match.Groups[1].Length == 0)
{
value = value.Replace(":", "/");
}
// if the value does not start with a scheme, we assume that it is ssh, not that it really matters
Regex schemeRegex = new Regex(@"\w*://.*");
if (!schemeRegex.Match(value).Success)
{
value = "ssh" + Uri.SchemeDelimiter + value;
}
var uri = new Uri(value);
// check to see if uri.Host is this server and fixup url
if (uri.GetLeftPart(UriPartial.Authority) ==
HttpContext.Current.Request.Url.GetLeftPart(UriPartial.Authority))
{
value = value.ToString().Replace("/git/", "/browse/");
}
// fixup github urls so that we can link there
if (uri.Host.Equals("github.com", StringComparison.OrdinalIgnoreCase))
{
value = Uri.UriSchemeHttps + Uri.SchemeDelimiter + uri.Host + uri.AbsolutePath;
// drop the .git if present
if (value.EndsWith(".git"))
{
value = value.Remove(value.Length - 4, 4);
}
}
// TODO support other sites?
}
items.Add(key, value);
line = reader.ReadLine();
}
submoduleList.Add(submodule, new SubmoduleInfo(items["path"], items["url"]));
var submodule = match.Groups[2].Value;
var items = new Dictionary<string, string>();
line = reader.ReadLine();
while (line != null && (match = itemsRegex.Match(line)).Groups.Count == 3)
{
string key = match.Groups[1].Value;
string value = match.Groups[2].Value;
// parse url to make is useable
if (key == "url")
{
// scp-like syntax is valid for git, but does not conform to uri standards
// so we need to fix it up
Regex scpLikeRegex = new Regex(@"\w*@.*:(\d*).*");
if ((match = scpLikeRegex.Match(value)).Groups.Count > 1 && match.Groups[1].Length == 0)
{
value = value.Replace(":", "/");
}
// if the value does not start with a scheme, we assume that it is ssh, not that it really matters
Regex schemeRegex = new Regex(@"\w*://.*");
if (!schemeRegex.Match(value).Success)
{
value = "ssh" + Uri.SchemeDelimiter + value;
}
var uri = new Uri(value);
// check to see if uri.Host is this server and fixup url
if (uri.GetLeftPart(UriPartial.Authority) ==
HttpContext.Current.Request.Url.GetLeftPart(UriPartial.Authority))
{
value = value.ToString().Replace("/git/", "/browse/");
}
// fixup github urls so that we can link there
if (uri.Host.Equals("github.com", StringComparison.OrdinalIgnoreCase))
{
value = Uri.UriSchemeHttps + Uri.SchemeDelimiter + uri.Host + uri.AbsolutePath;
// drop the .git if present
if (value.EndsWith(".git"))
{
value = value.Remove(value.Length - 4, 4);
}
}
// TODO support other sites?
}
items.Add(key, value);
line = reader.ReadLine();
}
submoduleList.Add(submodule, new SubmoduleInfo(items["path"], items["url"]));
}
catch
{
// ignore error
}
}
}
else
{
line = reader.ReadLine();
Expand Down
4 changes: 0 additions & 4 deletions WebGitNet.SharedLib/IRouteRegisterer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@

namespace WebGitNet
{
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.Routing;

public interface IRouteRegisterer
Expand Down
2 changes: 0 additions & 2 deletions WebGitNet.SharedLib/IgnoreFileParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,8 @@

namespace WebGitNet
{
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

public static class IgnoreFileParser
{
Expand Down
2 changes: 0 additions & 2 deletions WebGitNet.SharedLib/MimeUtilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@ namespace WebGitNet
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text.RegularExpressions;
using Microsoft.Win32;

public class MimeUtilities
Expand Down
2 changes: 0 additions & 2 deletions WebGitNet.SharedLib/PathUtilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@

namespace WebGitNet
{
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
Expand Down
2 changes: 0 additions & 2 deletions WebGitNet.SharedLib/PluginContentController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@
namespace WebGitNet
{
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.Mvc;

public class PluginContentController : Controller
Expand Down
5 changes: 0 additions & 5 deletions WebGitNet.SharedLib/RenameEntry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,6 @@

namespace WebGitNet
{
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

public enum RenameField
{
None = 0,
Expand Down
5 changes: 1 addition & 4 deletions WebGitNet/ActionResults/AtomActionResult.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,8 @@
namespace WebGitNet.ActionResults
{
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.ServiceModel.Syndication;
using System.Web.Mvc;
using System.Xml;

public class AtomActionResult : ActionResult
Expand Down
1 change: 1 addition & 0 deletions WebGitNet/Controllers/ManageController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ namespace WebGitNet.Controllers
using System.Web.Mvc;
using System.Web.Routing;
using WebGitNet.Models;

using io = System.IO;

public class ManageController : SharedControllerBase
Expand Down
7 changes: 2 additions & 5 deletions WebGitNet/Controllers/SearchController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,12 @@

namespace WebGitNet.Controllers
{
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Threading.Tasks;
using System.Web.Mvc;
using System.Web.Routing;
using WebGitNet.Search;
using Castle.Windsor;
using System.Threading.Tasks;
using WebGitNet.Search;

public class SearchController : SharedControllerBase
{
Expand Down
5 changes: 2 additions & 3 deletions WebGitNet/Controllers/SyndicationController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,11 @@ namespace WebGitNet.Controllers
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.ServiceModel.Syndication;
using System.Web.Mvc;
using System.Web.Routing;
using System.ServiceModel.Syndication;
using WebGitNet.ActionResults;
using MarkdownSharp;
using WebGitNet.ActionResults;

public class SyndicationController : SharedControllerBase
{
Expand Down
1 change: 0 additions & 1 deletion WebGitNet/Global.asax.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

namespace WebGitNet
{
using System.Linq;
using System.Web.Hosting;
using System.Web.Mvc;
using System.Web.Routing;
Expand Down
1 change: 0 additions & 1 deletion WebGitNet/HtmlHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

namespace WebGitNet
{
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Cryptography;
Expand Down
8 changes: 0 additions & 8 deletions WebGitNet/ResourceRazorViewEngine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,7 @@

namespace WebGitNet
{
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Security.Cryptography;
using System.Text;
using System.Threading;
using System.Web;
using System.Web.Mvc;

public class ResourceRazorViewEngine : RazorViewEngine
Expand Down

0 comments on commit 00353f6

Please sign in to comment.