mirror of
https://github.com/sourcegit-scm/sourcegit
synced 2025-05-20 19:55:00 +00:00
style: add .editorconfig for code formatting. see issu #25
This commit is contained in:
parent
a8eeea4f78
commit
18aaa0a143
225 changed files with 7781 additions and 3911 deletions
|
@ -2,28 +2,37 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace SourceGit.Commands {
|
||||
public partial class QueryBranches : Command {
|
||||
namespace SourceGit.Commands
|
||||
{
|
||||
public partial class QueryBranches : Command
|
||||
{
|
||||
private static readonly string PREFIX_LOCAL = "refs/heads/";
|
||||
private static readonly string PREFIX_REMOTE = "refs/remotes/";
|
||||
|
||||
|
||||
[GeneratedRegex(@"^(\d+)\s(\d+)$")]
|
||||
private static partial Regex REG_AHEAD_BEHIND();
|
||||
|
||||
public QueryBranches(string repo) {
|
||||
public QueryBranches(string repo)
|
||||
{
|
||||
WorkingDirectory = repo;
|
||||
Context = repo;
|
||||
Args = "branch -l --all -v --format=\"%(refname)$%(objectname)$%(HEAD)$%(upstream)$%(upstream:trackshort)\"";
|
||||
}
|
||||
|
||||
public List<Models.Branch> Result() {
|
||||
public List<Models.Branch> Result()
|
||||
{
|
||||
Exec();
|
||||
|
||||
foreach (var b in _branches) {
|
||||
if (b.IsLocal && !string.IsNullOrEmpty(b.UpstreamTrackStatus)) {
|
||||
if (b.UpstreamTrackStatus == "=") {
|
||||
foreach (var b in _branches)
|
||||
{
|
||||
if (b.IsLocal && !string.IsNullOrEmpty(b.UpstreamTrackStatus))
|
||||
{
|
||||
if (b.UpstreamTrackStatus == "=")
|
||||
{
|
||||
b.UpstreamTrackStatus = string.Empty;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
b.UpstreamTrackStatus = ParseTrackStatus(b.Name, b.Upstream);
|
||||
}
|
||||
}
|
||||
|
@ -32,7 +41,8 @@ namespace SourceGit.Commands {
|
|||
return _branches;
|
||||
}
|
||||
|
||||
protected override void OnReadline(string line) {
|
||||
protected override void OnReadline(string line)
|
||||
{
|
||||
var parts = line.Split('$');
|
||||
if (parts.Length != 5) return;
|
||||
|
||||
|
@ -40,10 +50,13 @@ namespace SourceGit.Commands {
|
|||
var refName = parts[0];
|
||||
if (refName.EndsWith("/HEAD", StringComparison.Ordinal)) return;
|
||||
|
||||
if (refName.StartsWith(PREFIX_LOCAL, StringComparison.Ordinal)) {
|
||||
if (refName.StartsWith(PREFIX_LOCAL, StringComparison.Ordinal))
|
||||
{
|
||||
branch.Name = refName.Substring(PREFIX_LOCAL.Length);
|
||||
branch.IsLocal = true;
|
||||
} else if (refName.StartsWith(PREFIX_REMOTE, StringComparison.Ordinal)) {
|
||||
}
|
||||
else if (refName.StartsWith(PREFIX_REMOTE, StringComparison.Ordinal))
|
||||
{
|
||||
var name = refName.Substring(PREFIX_REMOTE.Length);
|
||||
var shortNameIdx = name.IndexOf('/', StringComparison.Ordinal);
|
||||
if (shortNameIdx < 0) return;
|
||||
|
@ -51,7 +64,9 @@ namespace SourceGit.Commands {
|
|||
branch.Remote = name.Substring(0, shortNameIdx);
|
||||
branch.Name = name.Substring(branch.Remote.Length + 1);
|
||||
branch.IsLocal = false;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
branch.Name = refName;
|
||||
branch.IsLocal = true;
|
||||
}
|
||||
|
@ -64,7 +79,8 @@ namespace SourceGit.Commands {
|
|||
_branches.Add(branch);
|
||||
}
|
||||
|
||||
private string ParseTrackStatus(string local, string upstream) {
|
||||
private string ParseTrackStatus(string local, string upstream)
|
||||
{
|
||||
var cmd = new Command();
|
||||
cmd.WorkingDirectory = WorkingDirectory;
|
||||
cmd.Context = Context;
|
||||
|
@ -84,6 +100,6 @@ namespace SourceGit.Commands {
|
|||
return track.Trim();
|
||||
}
|
||||
|
||||
private List<Models.Branch> _branches = new List<Models.Branch>();
|
||||
private readonly List<Models.Branch> _branches = new List<Models.Branch>();
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue