Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GitAuto: [FEATURE] Preserve original message for merge conflict resolutions +semver: minor #114

Merged
merged 35 commits into from
Dec 12, 2024
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
a1011cd
Update Src/AiCommitMessage/Program.cs
gitauto-ai[bot] Nov 7, 2024
ed918f8
Update Src/AiCommitMessage/Options/GenerateCommitMessageOptions.cs
gitauto-ai[bot] Nov 7, 2024
5251d1c
Update Src/AiCommitMessage/Utility/Constants.cs
gitauto-ai[bot] Nov 7, 2024
7d228e1
Update Src/AiCommitMessage/Program.cs
gitauto-ai[bot] Nov 7, 2024
5c3544f
Update Src/AiCommitMessage/Program.cs
gitauto-ai[bot] Nov 7, 2024
6abb939
Update Src/AiCommitMessage/Program.cs
gitauto-ai[bot] Nov 7, 2024
a541beb
Update Src/AiCommitMessage/Program.cs
gitauto-ai[bot] Nov 7, 2024
22986fd
Update Src/AiCommitMessage/Program.cs
gitauto-ai[bot] Nov 7, 2024
3f4f1b2
Update Src/AiCommitMessage/Program.cs
gitauto-ai[bot] Nov 7, 2024
0fc4fc8
Update Src/AiCommitMessage/Program.cs
gitauto-ai[bot] Nov 7, 2024
ba2b973
Update Src/AiCommitMessage/Program.cs
gitauto-ai[bot] Nov 7, 2024
20607c9
Update Src/AiCommitMessage/AiCommitMessage.csproj
gitauto-ai[bot] Nov 7, 2024
134dd72
Merge branch 'main' into gitauto/issue-113-347f3d44-b7bf-48ef-97fb-29…
gstraccini[bot] Nov 11, 2024
6224f3c
Merge branch 'main' into gitauto/issue-113-347f3d44-b7bf-48ef-97fb-29…
gstraccini[bot] Nov 11, 2024
eb3c060
Merge branch 'main' into gitauto/issue-113-347f3d44-b7bf-48ef-97fb-29…
gstraccini[bot] Nov 12, 2024
f29ddab
Update AiCommitMessage.csproj
guibranco Dec 12, 2024
d6652ac
Merge branch 'main' into gitauto/issue-113-347f3d44-b7bf-48ef-97fb-29…
gstraccini[bot] Dec 12, 2024
e5b199c
Update GenerateCommitMessageOptions.cs
guibranco Dec 12, 2024
93fbf2d
Update Constants.cs
guibranco Dec 12, 2024
64833be
Update Program.cs
guibranco Dec 12, 2024
647afd4
Update GenerateCommitMessageService.cs
guibranco Dec 12, 2024
7b0c88f
Update Program.cs
guibranco Dec 12, 2024
123b971
Update GenerateCommitMessageService.cs
guibranco Dec 12, 2024
a584fcc
Update GenerateCommitMessageService.cs +semver: minor
guibranco Dec 12, 2024
667a335
Update GenerateCommitMessageService.cs
guibranco Dec 12, 2024
fc0d041
CSharpier format
gstraccini[bot] Dec 12, 2024
1f407ff
Update GenerateCommitMessageService.cs
guibranco Dec 12, 2024
a06632e
Create GenerateCommitMessageServiceTests.cs
guibranco Dec 12, 2024
a0404fd
Update GenerateCommitMessageServiceTests.cs
guibranco Dec 12, 2024
ebbe1c8
Update GenerateCommitMessageServiceTests.cs
guibranco Dec 12, 2024
afbcb5b
Update GenerateCommitMessageServiceTests.cs
guibranco Dec 12, 2024
f0935a1
Update GenerateCommitMessageServiceTests.cs
guibranco Dec 12, 2024
8242aa4
#113 fix - correcting test cases for better functionality
guibranco Dec 12, 2024
83c3a16
#113 fix - update environment variable setting in test file
guibranco Dec 12, 2024
8ad567c
#113 refactor - enhance regex options and adjust code structure
guibranco Dec 12, 2024
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
4 changes: 2 additions & 2 deletions Src/AiCommitMessage/AiCommitMessage.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net7.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>disable</Nullable>
<PackAsTool>true</PackAsTool>
Expand Down Expand Up @@ -52,4 +52,4 @@
<ItemGroup>
<EmbeddedResource Include="..\..\.githooks\prepare-commit-msg" />
</ItemGroup>
</Project>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace AiCommitMessage.Options;

/// <summary>
/// Includes options for detecting merge conflict resolution messages.
/// Class GenerateMessageOptions.
/// </summary>
[Verb("generate-message", HelpText = "Generate a commit message based on staged changes.")]
Expand Down
59 changes: 57 additions & 2 deletions Src/AiCommitMessage/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using AiCommitMessage.Services;
using AiCommitMessage.Utility;
using CommandLine;
using System.Text.RegularExpressions;

namespace AiCommitMessage;

Expand All @@ -13,6 +14,10 @@
internal static class Program
{
/// <summary>
private static readonly Regex MergeConflictPattern = new Regex(@"^Merge branch '.*' into .*$", RegexOptions.Compiled);

private static bool IsMergeConflictResolution(string message) => MergeConflictPattern.IsMatch(message);

/// The entry point of the application that processes command-line arguments.
/// </summary>
/// <param name="args">An array of strings representing the command-line arguments passed to the application.</param>
Expand All @@ -22,15 +27,66 @@
/// It calls the <c>Run</c> method if the parsing is successful, allowing the application to execute the intended functionality.
/// If the parsing fails, it invokes the <c>HandleErrors</c> method to manage any errors that occurred during parsing.
/// This structure allows for a clean and organized way to handle different command-line options and their corresponding actions.

/// </remarks>
private static void Main(string[] args) =>
private static void Main(string[] args)
{
var options = Parser.Default.ParseArguments<GenerateCommitMessageOptions>(args)
.WithParsed(RunGenerateCommitMessage)
.WithNotParsed(HandleErrors);

if (IsMergeConflictResolution(options.Message))
{
Console.WriteLine(options.Message); // Preserve original message
return;
}

Parser.Default.ParseArguments<InstallHookOptions>(args)
.WithParsed(RunInstallHook)
.WithNotParsed(HandleErrors);
{
var options = // ... initialize options as needed

Check failure on line 48 in Src/AiCommitMessage/Program.cs

View workflow job for this annotation

GitHub Actions / Build

Invalid expression term 'if'

Check failure on line 48 in Src/AiCommitMessage/Program.cs

View workflow job for this annotation

GitHub Actions / Build

; expected

Check failure on line 48 in Src/AiCommitMessage/Program.cs

View workflow job for this annotation

GitHub Actions / Deep Source Coverage report

Invalid expression term 'if'

Check failure on line 48 in Src/AiCommitMessage/Program.cs

View workflow job for this annotation

GitHub Actions / Deep Source Coverage report

; expected

if (IsMergeConflictResolution(options.Message))
{
Console.WriteLine(options.Message); // Preserve original message
return;
}

// Existing code for handling non-merge conflict commit messages
Parser
.Default.ParseArguments<
InstallHookOptions,

Check failure on line 59 in Src/AiCommitMessage/Program.cs

View workflow job for this annotation

GitHub Actions / Build

Type expected

Check failure on line 59 in Src/AiCommitMessage/Program.cs

View workflow job for this annotation

GitHub Actions / Deep Source Coverage report

Type expected
// ... other options
>(args)
.WithParsed<InstallHookOptions>(opts => RunInstall(opts))
// ... other parsers
;
{
if (IsMergeConflictResolution(options.Message))
{
Console.WriteLine(options.Message); // Preserve original message
return;
}
}
if (IsMergeConflictResolution(options.Message))
{
Console.WriteLine(options.Message); // Preserve original message
return;
}

Parser
.Default.ParseArguments<
InstallHookOptions,

Check failure on line 80 in Src/AiCommitMessage/Program.cs

View workflow job for this annotation

GitHub Actions / Build

; expected

Check failure on line 80 in Src/AiCommitMessage/Program.cs

View workflow job for this annotation

GitHub Actions / Build

} expected

Check failure on line 80 in Src/AiCommitMessage/Program.cs

View workflow job for this annotation

GitHub Actions / Deep Source Coverage report

; expected

Check failure on line 80 in Src/AiCommitMessage/Program.cs

View workflow job for this annotation

GitHub Actions / Deep Source Coverage report

} expected
}
}
Parser
.Default.ParseArguments<
InstallHookOptions,
GenerateCommitMessageOptions,
SetSettingsOptions
>(args)

Check failure on line 88 in Src/AiCommitMessage/Program.cs

View workflow job for this annotation

GitHub Actions / Build

Invalid token '(' in class, record, struct, or interface member declaration

Check failure on line 88 in Src/AiCommitMessage/Program.cs

View workflow job for this annotation

GitHub Actions / Build

Tuple must contain at least two elements.

Check failure on line 88 in Src/AiCommitMessage/Program.cs

View workflow job for this annotation

GitHub Actions / Deep Source Coverage report

Invalid token '(' in class, record, struct, or interface member declaration

Check failure on line 88 in Src/AiCommitMessage/Program.cs

View workflow job for this annotation

GitHub Actions / Deep Source Coverage report

Tuple must contain at least two elements.
.WithParsed(Run)

Check failure on line 89 in Src/AiCommitMessage/Program.cs

View workflow job for this annotation

GitHub Actions / Build

Invalid token '.' in class, record, struct, or interface member declaration

Check failure on line 89 in Src/AiCommitMessage/Program.cs

View workflow job for this annotation

GitHub Actions / Build

Identifier expected

Check failure on line 89 in Src/AiCommitMessage/Program.cs

View workflow job for this annotation

GitHub Actions / Build

; expected

Check failure on line 89 in Src/AiCommitMessage/Program.cs

View workflow job for this annotation

GitHub Actions / Deep Source Coverage report

Invalid token '.' in class, record, struct, or interface member declaration

Check failure on line 89 in Src/AiCommitMessage/Program.cs

View workflow job for this annotation

GitHub Actions / Deep Source Coverage report

Identifier expected

Check failure on line 89 in Src/AiCommitMessage/Program.cs

View workflow job for this annotation

GitHub Actions / Deep Source Coverage report

; expected
.WithNotParsed(HandleErrors);

/// <summary>
Expand Down Expand Up @@ -100,4 +156,3 @@
Output.ErrorLine("Invalid command-line arguments.");
Environment.ExitCode = 2;
}
}
3 changes: 3 additions & 0 deletions Src/AiCommitMessage/Utility/Constants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
/// <summary>
/// Class Constants.
/// </summary>
/// Includes constants for system messages and patterns.
///
/// <remarks>Used for commit message generation and detection.</remarks>
public class Constants
{
/// <summary>
Expand Down
Loading