Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions GitTools.sln.DotSettings
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=ConvertToExtensionBlock/@EntryIndexedValue">DO_NOT_SHOW</s:String>
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpCodeStyle/OBJECT_CREATION_WHEN_TYPE_EVIDENT/@EntryValue">ExplicitlyTyped</s:String>
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/LINE_FEED_AT_FILE_END/@EntryValue">True</s:Boolean>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=PrivateStaticFields/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /&gt;</s:String>
Expand Down
2 changes: 1 addition & 1 deletion build/Build.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="CreativeCoders.CakeBuild" Version="6.2.0"/>
<PackageReference Include="CreativeCoders.CakeBuild" Version="6.5.0"/>
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="CreativeCoders.Core" Version="6.2.0"/>
<PackageReference Include="CreativeCoders.Core" Version="6.5.0"/>
<PackageReference Include="JetBrains.Annotations" Version="2025.2.4"/>

</ItemGroup>
Expand Down
4 changes: 2 additions & 2 deletions source/Git/CreativeCoders.Git.Abstractions/GitMergeOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ public class GitMergeOptions
/// <summary>
/// Similarity to consider a file renamed.
/// </summary>
public int RenameThreshold = 50;
public int RenameThreshold { get; set; } = 50;

/// <summary>
/// Maximum similarity sources to examine (overrides
/// 'merge.renameLimit' config (default 200)
/// </summary>
public int TargetLimit = 200;
public int TargetLimit { get; set; } = 200;

public GitFastForwardStrategy FastForwardStrategy { get; set; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@ namespace CreativeCoders.Git.Abstractions.Pushes;

public class GitPushUpdate
{
public GitPushUpdate(IGitObjectId sourceObjectId, string sourceRefName, IGitObjectId destinationObjectId, string destinationRefName)
public GitPushUpdate(IGitObjectId sourceObjectId, string sourceRefName, IGitObjectId destinationObjectId,
string destinationRefName)
{
SourceObjectId = Ensure.NotNull(sourceObjectId, nameof(sourceObjectId));
SourceObjectId = Ensure.NotNull(sourceObjectId);
SourceRefName = sourceRefName;
DestinationObjectId = Ensure.NotNull(destinationObjectId, nameof(destinationObjectId));
DestinationObjectId = Ensure.NotNull(destinationObjectId);
DestinationRefName = destinationRefName;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace CreativeCoders.Git.Auth.CredentialManagerCore;
[ExcludeFromCodeCoverage]
internal class DefaultGcmCoreCredentialStore : IGcmCoreCredentialStore
{
public ICredentialStore Create(string? credentialsNameSpace = default)
public ICredentialStore Create(string? credentialsNameSpace = null)
{
return CredentialManager.Create(credentialsNameSpace);
}
Expand Down
4 changes: 2 additions & 2 deletions source/Git/CreativeCoders.Git/Branches/GitBranch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public class GitBranch : ComparableObject<GitBranch, IGitBranch>, IGitBranch

internal GitBranch(Branch branch)
{
_branch = Ensure.NotNull(branch, nameof(branch));
_branch = Ensure.NotNull(branch);

Name = new ReferenceName(branch.CanonicalName);
Tip = GitCommit.From(branch.Tip);
Expand Down Expand Up @@ -43,4 +43,4 @@ internal GitBranch(Branch branch)
public IGitCommitLog? Commits { get; }

public static implicit operator Branch(GitBranch branch) => branch._branch;
}
}
6 changes: 3 additions & 3 deletions source/Git/CreativeCoders.Git/Commits/GitCommit.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@

namespace CreativeCoders.Git.Commits;

public class GitCommit : Objects.GitObject, IGitCommit
public sealed class GitCommit : Objects.GitObject, IGitCommit
{
private readonly Commit _commit;

internal GitCommit(Commit commit) : base(commit)
{
_commit = Ensure.NotNull(commit, nameof(commit));
_commit = Ensure.NotNull(commit);

Parents = _commit.Parents.Select(x => new GitCommit(x));
Author = new GitSignature(_commit.Author);
Expand Down Expand Up @@ -43,4 +43,4 @@ public int CompareTo(IGitCommit? other)
public string Message => _commit.Message;

public static implicit operator Commit(GitCommit commit) => commit._commit;
}
}
4 changes: 2 additions & 2 deletions source/Git/CreativeCoders.Git/Commits/GitCommitLog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ public class GitCommitLog : IGitCommitLog

internal GitCommitLog(ICommitLog commitLog)
{
_commitLog = Ensure.NotNull(commitLog, nameof(commitLog));
_commitLog = Ensure.NotNull(commitLog);
}

internal static GitCommitLog? From(ICommitLog? commitLog)
Expand All @@ -33,4 +33,4 @@ public IEnumerable<IGitCommit> QueryBy(GitCommitFilter commitFilter)
{
throw new NotImplementedException();
}
}
}
2 changes: 1 addition & 1 deletion source/Git/CreativeCoders.Git/Common/GitSignature.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ public class GitSignature : IGitSignature

public GitSignature(Signature signature)
{
_signature = Ensure.NotNull(signature, nameof(signature));
_signature = Ensure.NotNull(signature);
}

public DateTimeOffset When => _signature.When;
Expand Down
2 changes: 1 addition & 1 deletion source/Git/CreativeCoders.Git/CreativeCoders.Git.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="CreativeCoders.Core" Version="6.2.0"/>
<PackageReference Include="CreativeCoders.Core" Version="6.5.0"/>
<PackageReference Include="LibGit2Sharp" Version="0.31.0"/>
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="10.0.2"/>
</ItemGroup>
Expand Down
4 changes: 2 additions & 2 deletions source/Git/CreativeCoders.Git/Diffs/GitDiffer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ public class GitDiffer : IGitDiffer

public GitDiffer(Diff diff)
{
_diff = Ensure.NotNull(diff, nameof(diff));
_diff = Ensure.NotNull(diff);
}

public IGitTreeChanges Compare()
Expand All @@ -30,4 +30,4 @@ public IGitTreeChanges Compare(IEnumerable<string> paths, bool includeUntracked)
{
return new GitTreeChanges(_diff.Compare<TreeChanges>(paths, includeUntracked));
}
}
}
4 changes: 2 additions & 2 deletions source/Git/CreativeCoders.Git/Diffs/GitTreeChanges.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ public sealed class GitTreeChanges : IGitTreeChanges

internal GitTreeChanges(TreeChanges treeChanges)
{
_treeChanges = Ensure.NotNull(treeChanges, nameof(treeChanges));
_treeChanges = Ensure.NotNull(treeChanges);
}

public IEnumerator<IGitTreeEntryChanges> GetEnumerator()
Expand Down Expand Up @@ -53,4 +53,4 @@ public IEnumerable<IGitTreeEntryChanges> Conflicted
=> ToGitTreeEntryChanges(_treeChanges.Conflicted);

public int Count => _treeChanges.Count;
}
}
4 changes: 2 additions & 2 deletions source/Git/CreativeCoders.Git/Diffs/GitTreeEntryChanges.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public class GitTreeEntryChanges : IGitTreeEntryChanges

internal GitTreeEntryChanges(TreeEntryChanges treeEntryChanges)
{
_treeEntryChanges = Ensure.NotNull(treeEntryChanges, nameof(treeEntryChanges));
_treeEntryChanges = Ensure.NotNull(treeEntryChanges);

Mode = treeEntryChanges.Mode.ToGitEntryMode();
Oid = new GitObjectId(treeEntryChanges.Oid);
Expand All @@ -37,4 +37,4 @@ internal GitTreeEntryChanges(TreeEntryChanges treeEntryChanges)
public IGitObjectId OldOid { get; }

public bool OldExists => _treeEntryChanges.OldExists;
}
}
4 changes: 2 additions & 2 deletions source/Git/CreativeCoders.Git/Objects/GitObjectId.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ public class GitObjectId : ComparableObject<GitObjectId, IGitObjectId>, IGitObje

internal GitObjectId(ObjectId objectId)
{
_objectId = Ensure.NotNull(objectId, nameof(objectId));
_objectId = Ensure.NotNull(objectId);
}

public GitObjectId(string sha) : this(new ObjectId(sha))
Expand All @@ -25,4 +25,4 @@ static GitObjectId()
public string Sha => _objectId.Sha;

public string ToString(int prefixLength) => _objectId.ToString(prefixLength);
}
}
4 changes: 2 additions & 2 deletions source/Git/CreativeCoders.Git/RefSpecs/GitRefSpec.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public class GitRefSpec : ComparableObject<GitRefSpec, IGitRefSpec>, IGitRefSpec

internal GitRefSpec(RefSpec refSpec)
{
_refSpec = Ensure.NotNull(refSpec, nameof(refSpec));
_refSpec = Ensure.NotNull(refSpec);
}

static GitRefSpec() => InitComparableObject(x => x.Specification);
Expand All @@ -25,4 +25,4 @@ internal GitRefSpec(RefSpec refSpec)
public override string ToString() => Specification;

public static implicit operator RefSpec(GitRefSpec refSpec) => refSpec._refSpec;
}
}
4 changes: 2 additions & 2 deletions source/Git/CreativeCoders.Git/References/GitReference.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public class GitReference : ComparableObject<GitReference, IGitReference>, IGitR

internal GitReference(Reference reference)
{
_reference = Ensure.NotNull(reference, nameof(reference));
_reference = Ensure.NotNull(reference);

Name = new ReferenceName(reference.CanonicalName);

Expand All @@ -37,4 +37,4 @@ internal GitReference(Reference reference)
public IGitObjectId? ReferenceTargetId { get; }

public static implicit operator Reference(GitReference reference) => reference._reference;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public class GitReferenceCollection : IGitReferenceCollection

internal GitReferenceCollection(ReferenceCollection referenceCollection)
{
_referenceCollection = Ensure.NotNull(referenceCollection, nameof(referenceCollection));
_referenceCollection = Ensure.NotNull(referenceCollection);
}

public IEnumerator<IGitReference> GetEnumerator()
Expand All @@ -39,4 +39,4 @@ public void UpdateTarget(IGitReference directRef, IGitObjectId targetId)

public IEnumerable<IGitReference> FromGlob(string prefix)
=> _referenceCollection.FromGlob(prefix).Select(x => new GitReference(x));
}
}
4 changes: 2 additions & 2 deletions source/Git/CreativeCoders.Git/Remotes/GitRemoteCollection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ public class GitRemoteCollection : IGitRemoteCollection

public GitRemoteCollection(RemoteCollection remoteCollection)
{
_remoteCollection = Ensure.NotNull(remoteCollection, nameof(remoteCollection));
_remoteCollection = Ensure.NotNull(remoteCollection);
}

public IEnumerator<IGitRemote> GetEnumerator()
Expand All @@ -20,4 +20,4 @@ IEnumerator IEnumerable.GetEnumerator()
}

public IGitRemote? this[string name] => GitRemote.From(_remoteCollection[name]);
}
}
4 changes: 2 additions & 2 deletions source/Git/CreativeCoders.Git/Tags/GitTag.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public class GitTag : ComparableObject<GitTag, IGitTag>, IGitTag

internal GitTag(Tag tag)
{
_tag = Ensure.NotNull(tag, nameof(tag));
_tag = Ensure.NotNull(tag);

Name = new ReferenceName(_tag.CanonicalName);
}
Expand All @@ -35,4 +35,4 @@ internal GitTag(Tag tag)
}

public static implicit operator Tag(GitTag tag) => tag._tag;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace CreativeCoders.GitTool.Base.Configurations;

internal class DefaultRepositoryConfigurations : IRepositoryConfigurations
{
private static readonly JsonSerializerOptions __jsonSerializerOptions = new JsonSerializerOptions()
private static readonly JsonSerializerOptions __jsonSerializerOptions = new JsonSerializerOptions
{
DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="10.0.2"/>
<PackageReference Include="CreativeCoders.Core" Version="6.2.0"/>
<PackageReference Include="CreativeCoders.Core" Version="6.5.0"/>
<PackageReference Include="Microsoft.Extensions.Options" Version="10.0.2"/>
<PackageReference Include="Spectre.Console" Version="0.54.0"/>
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,7 @@ public async Task<IGitServiceProvider> GetServiceProviderAsync(IGitRepository gi

var gitServiceProvider = await providerFactory.CreateProviderAsync(gitRepository).ConfigureAwait(false);

if (gitServiceProvider == null)
{
throw new GitServiceProviderNotFoundException();
}

return gitServiceProvider;
return gitServiceProvider ?? throw new GitServiceProviderNotFoundException();
}

public IEnumerable<string> ProviderNames => _providerFactories.Select(x => x.ProviderName);
Expand Down
20 changes: 6 additions & 14 deletions source/GitTool/CreativeCoders.GitTool.Base/GitCreatePullRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,15 @@

namespace CreativeCoders.GitTool.Base;

public class GitCreatePullRequest
public class GitCreatePullRequest(Uri projectUrl, string title, string sourceBranch, string targetBranch)
{
public GitCreatePullRequest(Uri projectUrl, string title, string sourceBranch, string targetBranch)
{
RepositoryUrl = Ensure.NotNull(projectUrl, nameof(projectUrl));
Title = Ensure.IsNotNullOrWhitespace(title, nameof(title));
SourceBranch = Ensure.IsNotNullOrWhitespace(sourceBranch, nameof(sourceBranch));
TargetBranch = Ensure.IsNotNullOrWhitespace(targetBranch, nameof(targetBranch));
}
public Uri RepositoryUrl { get; } = Ensure.NotNull(projectUrl);

public Uri RepositoryUrl { get; }
public string Title { get; } = Ensure.IsNotNullOrWhitespace(title);

public string Title { get; }
public string SourceBranch { get; } = Ensure.IsNotNullOrWhitespace(sourceBranch);

public string SourceBranch { get; }

public string TargetBranch { get; }
public string TargetBranch { get; } = Ensure.IsNotNullOrWhitespace(targetBranch);

public string? Description { get; set; }
}
}
4 changes: 3 additions & 1 deletion source/GitTool/CreativeCoders.GitTool.Base/ReturnCodes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,6 @@ public static class ReturnCodes
public const int MergeConflicts = -3;

public const int BranchHasUncommittedChanges = -4;
}

public const int NoGitRepositoryFound = -5;
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ public class InfoBranchesCommand(IAnsiConsole ansiConsole, IGitRepository gitRep
{
private readonly IAnsiConsole _ansiConsole = Ensure.NotNull(ansiConsole);

private readonly IGitRepository _gitRepository = Ensure.NotNull(gitRepository);

public Task<CommandResult> ExecuteAsync(InfoBranchesOptions options)
{
_ansiConsole.WriteLine("Branch info");
Expand All @@ -24,20 +26,20 @@ public Task<CommandResult> ExecuteAsync(InfoBranchesOptions options)
.HideHeaders()
.AddColumn("Name")
.AddColumn("Value")
.AddRow("Current branch:", gitRepository.Head.Name.Canonical)
.AddRow("Last Commit:", gitRepository.Head.Tip?.Sha ?? string.Empty);
.AddRow("Current branch:", _gitRepository.Head.Name.Canonical)
.AddRow("Last Commit:", _gitRepository.Head.Tip?.Sha ?? string.Empty);

if (gitRepository.Head.TrackedBranch != null)
if (_gitRepository.Head.TrackedBranch != null)
{
table.AddRow("Last tracked commit:", gitRepository.Head.TrackedBranch?.Tip?.Sha ?? string.Empty);
table.AddRow("Last tracked commit:", _gitRepository.Head.TrackedBranch?.Tip?.Sha ?? string.Empty);
}

_ansiConsole.Write(table);

_ansiConsole.WriteLine();
_ansiConsole.WriteLine("Last commits");

var commits = gitRepository.Head.Commits?.Take(options.CommitLogCount);
var commits = _gitRepository.Head.Commits?.Take(options.CommitLogCount);

if (commits != null)
{
Expand Down
Loading