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

fix git merge integration #140

Merged
merged 2 commits into from
Oct 24, 2023
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
2 changes: 1 addition & 1 deletion src/Joba.IBM.RPA.Cli/SourceControl/GitCommand.Config.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ namespace Joba.IBM.RPA.Cli
internal partial class GitCommand
{
internal static readonly string GitDiffCommandLine = $"{RpaCommand.CommandName} {GitCommand.CommandName} {GitCommand.DiffCommand.CommandName} \"$1\"";
internal static readonly string GitMergeCommandLine = $"{RpaCommand.CommandName} {GitCommand.CommandName} {GitCommand.MergeCommand.CommandName} %O %A %B";
internal static readonly string GitMergeCommandLine = $"{RpaCommand.CommandName} {GitCommand.CommandName} {GitCommand.MergeCommand.CommandName} %O %A %B -v";

internal class ConfigureCommand : Command
{
Expand Down
2 changes: 1 addition & 1 deletion src/Joba.IBM.RPA.Cli/SourceControl/GitCommand.Merge.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ private async Task HandleAsync(FileInfo baseFile, FileInfo localFile, FileInfo r

//TODO: not working... the 'base' file is corrupted by git :(
logger.LogDebug("Reading base {File} (exists={Exists})", baseFile, baseFile.Exists);
File.Copy(baseFile.FullName, @"C:\Users\002742631\Desktop\base.wal", true);
//Console.ReadLine();
var baseWal = WalFile.Read(baseFile);
logger.LogDebug("Reading local {File}", localFile);
var localWal = WalFile.Read(localFile);
Expand Down
21 changes: 1 addition & 20 deletions src/Joba.IBM.RPA/Git/GitConfigurator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ internal GitAttributes(DirectoryInfo workingDir, string cliName)
internal GitAttributes(FileInfo file, string cliName)
{
this.file = file;
pattern = $"*{WalFile.Extension} diff={cliName} merge={cliName}";
pattern = $"*{WalFile.Extension} diff={cliName} merge={cliName} -text";
comment = $"# DO NOT EDIT next line - auto-generated by '{cliName}'";
}

Expand Down Expand Up @@ -350,7 +350,6 @@ private async Task ConfigureMergeDriverAsync(CancellationToken cancellation)

await ConfigureNameAsync(cancellation);
await ConfigureDriverAsync(cancellation);
await ConfigureRecursiveAsync(cancellation);

async Task ConfigureNameAsync(CancellationToken cancellation)
{
Expand Down Expand Up @@ -387,24 +386,6 @@ async Task ConfigureDriverAsync(CancellationToken cancellation)
logger.LogInformation("Git output: {Output}", output);
await process.WaitForExitAsync(cancellation);
}

async Task ConfigureRecursiveAsync(CancellationToken cancellation)
{
var fileName = "git";
var arguments = $"config --global merge.{cliName}.recursive text";
logger.LogDebug("Executing {FileName} {Arguments}", fileName, arguments);

var info = new ProcessStartInfo(fileName, arguments) { UseShellExecute = false, RedirectStandardError = true, RedirectStandardOutput = true };
var process = Process.Start(info);
if (process == null)
throw new Exception($"Could not start '{info.FileName} {info.Arguments}'");
process.ErrorDataReceived += OnGitError;
process.BeginErrorReadLine();
var output = await process.StandardOutput.ReadToEndAsync(cancellation);
if (!string.IsNullOrEmpty(output))
logger.LogInformation("Git output: {Output}", output);
await process.WaitForExitAsync(cancellation);
}
}

private void OnGitError(object sender, DataReceivedEventArgs e)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@
*.sh text eol=lf

# DO NOT EDIT next line - auto-generated by 'rpa'
*.wal diff=rpa merge=rpa
*.wal diff=rpa merge=rpa -text
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
*.ps1 text working-tree-encoding=UTF-16

# DO NOT EDIT next line - auto-generated by 'rpa'
*.wal diff=rpa merge=rpa
*.wal diff=rpa merge=rpa -text

# DO NOT EDIT: File is auto-generated
*.cmd text eol=crlf
Expand Down
Loading