Skip to content

Commit

Permalink
Cleaning up code style.
Browse files Browse the repository at this point in the history
  • Loading branch information
otac0n committed Sep 23, 2011
1 parent bb99a0a commit ab183ad
Show file tree
Hide file tree
Showing 15 changed files with 117 additions and 40 deletions.
9 changes: 8 additions & 1 deletion WebGitNet.RepoImpact/AssemblyInstaller.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
namespace WebGitNet.RepoImpact
//-----------------------------------------------------------------------
// <copyright file="AssemblyInstaller.cs" company="(none)">
// Copyright © 2011 John Gietzen. All rights reserved.
// </copyright>
// <author>John Gietzen</author>
//-----------------------------------------------------------------------

namespace WebGitNet.RepoImpact
{
using System.Web.Mvc;
using Castle.MicroKernel.Registration;
Expand Down
11 changes: 9 additions & 2 deletions WebGitNet.RepoImpact/Controllers/ImpactController.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
namespace WebGitNet.Controllers
//-----------------------------------------------------------------------
// <copyright file="ImpactController.cs" company="(none)">
// Copyright © 2011 John Gietzen. All rights reserved.
// </copyright>
// <author>John Gietzen</author>
//-----------------------------------------------------------------------

namespace WebGitNet.Controllers
{
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Web.Mvc;
using System.Web.Routing;
using System.Globalization;
using WebGitNet.Models;

public class ImpactController : SharedControllerBase
Expand Down
9 changes: 8 additions & 1 deletion WebGitNet.RepoImpact/Models/ImpactWeek.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
namespace WebGitNet.Models
//-----------------------------------------------------------------------
// <copyright file="ImpactWeek.cs" company="(none)">
// Copyright © 2011 John Gietzen. All rights reserved.
// </copyright>
// <author>John Gietzen</author>
//-----------------------------------------------------------------------

namespace WebGitNet.Models
{
using System;
using System.Collections.Generic;
Expand Down
9 changes: 8 additions & 1 deletion WebGitNet.RepoImpact/Models/RepoImpact.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
namespace WebGitNet.Models
//-----------------------------------------------------------------------
// <copyright file="RepoImpact.cs" company="(none)">
// Copyright © 2011 John Gietzen. All rights reserved.
// </copyright>
// <author>John Gietzen</author>
//-----------------------------------------------------------------------

namespace WebGitNet.Models
{
using System.Linq;

Expand Down
15 changes: 12 additions & 3 deletions WebGitNet.SharedLib/GitErrorException.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,19 @@ public GitErrorException(string command, int exitCode, string errorOutput)
this.errorOutput = errorOutput;
}

public string Command { get { return this.command; } }
public string Command
{
get { return this.command; }
}

public int ExitCode { get { return this.exitCode; } }
public int ExitCode
{
get { return this.exitCode; }
}

public string ErrorOutput { get { return this.errorOutput; } }
public string ErrorOutput
{
get { return this.errorOutput; }
}
}
}
3 changes: 3 additions & 0 deletions WebGitNet.SharedLib/GitRef.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,11 @@ public GitRef(string shaId, string refPath)
}

public string ShaId { get; private set; }

public string Name { get; private set; }

public string RefPath { get; private set; }

public RefType RefType { get; private set; }
}
}
34 changes: 28 additions & 6 deletions WebGitNet.SharedLib/GitUtilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ private static string Q(string argument)
break;
}
}

result.Append("\"");
return result.ToString();
}
Expand Down Expand Up @@ -189,22 +190,39 @@ public static List<LogEntry> GetLogEntries(string repoPath, int count, int skip
private class Author
{
public string Name { get; set; }

public string Email { get; set; }
}

private static Author Rename(Author author, IList<RenameEntry> entries)
{
Func<RenameField, Author, string> getField = (f, a) =>
{
if (f == RenameField.Name) return a.Name;
if (f == RenameField.Email) return a.Email;
if (f == RenameField.Name)
{
return a.Name;
}

if (f == RenameField.Email)
{
return a.Email;
}

return null;
};

Action<RenameField, Author, string> setField = (f, a, v) =>
{
if (f == RenameField.Name) a.Name = v;
if (f == RenameField.Email) a.Email = v;
if (f == RenameField.Name)
{
a.Name = v;
}

if (f == RenameField.Email)
{
a.Email = v;
}

return;
};

Expand All @@ -222,6 +240,7 @@ private static Author Rename(Author author, IList<RenameEntry> entries)
setField(dest.Field, author, dest.Replacement);
}
}

break;

case RenameStyle.CaseInsensitive:
Expand All @@ -232,6 +251,7 @@ private static Author Rename(Author author, IList<RenameEntry> entries)
setField(dest.Field, author, dest.Replacement);
}
}

break;

case RenameStyle.Regex:
Expand All @@ -242,8 +262,10 @@ private static Author Rename(Author author, IList<RenameEntry> entries)
{
setField(dest.Field, newAuthor, Regex.Replace(getField(entry.SourceField, author), entry.Match, dest.Replacement));
}

author = newAuthor;
}

break;
}
}
Expand All @@ -253,7 +275,7 @@ private static Author Rename(Author author, IList<RenameEntry> entries)

public static Dictionary<string, int> GetLanguageLines(string repoPath)
{
const string fakeHash = "0000000000000000000000000000000000000000";
const string FakeHash = "0000000000000000000000000000000000000000";

var result = Execute("diff-tree -z --numstat 4b825dc642cb6eb9a060e54bf8d69288fbee4904 HEAD", repoPath);
var fileStats = result.Split("\0".ToArray(), StringSplitOptions.RemoveEmptyEntries);
Expand All @@ -273,7 +295,7 @@ public static Dictionary<string, int> GetLanguageLines(string repoPath)
continue;
}

bool keepPath = ProcessIgnores(ignores, fakeHash, path);
bool keepPath = ProcessIgnores(ignores, FakeHash, path);
if (!keepPath)
{
continue;
Expand Down
10 changes: 5 additions & 5 deletions WebGitNet.SharedLib/IgnoreEntry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,9 @@

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

public class IgnoreEntry
{
Expand Down Expand Up @@ -75,7 +72,10 @@ public bool IsMatch(string path)
}
}

if (match) return true;
if (match)
{
return true;
}
}

return false;
Expand Down
2 changes: 1 addition & 1 deletion WebGitNet.SharedLib/IgnoreFileParser.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//-----------------------------------------------------------------------
// <copyright file="IgnoreFilerParser.cs" company="(none)">
// <copyright file="IgnoreFileParser.cs" company="(none)">
// Copyright © 2011 John Gietzen. All rights reserved.
// </copyright>
// <author>John Gietzen</author>
Expand Down
9 changes: 8 additions & 1 deletion WebGitNet.SharedLib/PathUtilities.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
namespace WebGitNet
//-----------------------------------------------------------------------
// <copyright file="PathUtilities.cs" company="(none)">
// Copyright © 2011 John Gietzen. All rights reserved.
// </copyright>
// <author>John Gietzen</author>
//-----------------------------------------------------------------------

namespace WebGitNet
{
using System;
using System.Collections.Generic;
Expand Down
6 changes: 4 additions & 2 deletions WebGitNet.SharedLib/RenameFileParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -101,13 +101,15 @@ private static RenameEntry Parse(string line)
RenameEntry.Destination[] destinations;
if (destinationField2 == RenameField.None)
{
destinations = new[] {
destinations = new[]
{
new RenameEntry.Destination { Field = destinationField1, Replacement = destinationValue1 },
};
}
else
{
destinations = new[] {
destinations = new[]
{
new RenameEntry.Destination { Field = destinationField1, Replacement = destinationValue1 },
new RenameEntry.Destination { Field = destinationField2, Replacement = destinationValue2 },
};
Expand Down
10 changes: 5 additions & 5 deletions WebGitNet/Controllers/BrowseController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ namespace WebGitNet.Controllers
using System.Linq;
using System.Text.RegularExpressions;
using System.Web.Mvc;
using System.Web.Routing;
using WebGitNet.ActionResults;
using WebGitNet.Models;
using System.Web.Routing;

public class BrowseController : SharedControllerBase
{
Expand Down Expand Up @@ -87,8 +87,8 @@ public ActionResult ViewCommits(string repo, int page = 1)
return HttpNotFound();
}

const int pageSize = 20;
int skip = pageSize * (page - 1);
const int PageSize = 20;
int skip = PageSize * (page - 1);
var count = GitUtilities.CountCommits(resourceInfo.FullPath);

if (skip >= count)
Expand All @@ -99,10 +99,10 @@ public ActionResult ViewCommits(string repo, int page = 1)
AddRepoBreadCrumb(repo);
this.BreadCrumbs.Append("Browse", "ViewCommits", "Commit Log", new { repo });

var commits = GitUtilities.GetLogEntries(resourceInfo.FullPath, pageSize, skip);
var commits = GitUtilities.GetLogEntries(resourceInfo.FullPath, PageSize, skip);

ViewBag.Page = page;
ViewBag.PageCount = (count / pageSize) + (count % pageSize > 0 ? 1 : 0);
ViewBag.PageCount = (count / PageSize) + (count % PageSize > 0 ? 1 : 0);
ViewBag.RepoName = resourceInfo.Name;

return View(commits);
Expand Down
1 change: 0 additions & 1 deletion WebGitNet/Controllers/FileController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@ public void RegisterRoutes(RouteCollection routes)
"File Access",
"git/{*url}",
new { controller = "File", action = "Fetch" });

}
}
}
Expand Down
2 changes: 1 addition & 1 deletion WebGitNet/Global.asax.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ namespace WebGitNet
using System.Web.Mvc;
using System.Web.Routing;
using Castle.MicroKernel.Registration;
using Castle.MicroKernel.SubSystems.Configuration;
using Castle.Windsor;
using Castle.Windsor.Installer;
using Castle.MicroKernel.SubSystems.Configuration;

public partial class WebGitNetApplication : System.Web.HttpApplication
{
Expand Down
27 changes: 17 additions & 10 deletions WebGitNet/ResourceRazorViewEngine.cs
Original file line number Diff line number Diff line change
@@ -1,16 +1,23 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Reflection;
using System.IO;
using System.Security.Cryptography;
using System.Text;
using System.Threading;
//-----------------------------------------------------------------------
// <copyright file="ResourceRazorViewEngine.cs" company="(none)">
// Copyright © 2011 John Gietzen. All rights reserved.
// </copyright>
// <author>John Gietzen</author>
//-----------------------------------------------------------------------

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
{
private Dictionary<string, string> resourceHashChache = new Dictionary<string, string>();
Expand Down

0 comments on commit ab183ad

Please sign in to comment.