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

Append random id to log files so they get ignored during git-diff #285

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
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
6 changes: 5 additions & 1 deletion src/jit-dasm-pmi/jit-dasm-pmi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,7 @@ private class DisasmEnginePmi
public bool doDebugDump = false;
public bool verbose = false;
private int _errorCount = 0;
private Random _rand = new Random();

public int ErrorCount { get { return _errorCount; } }

Expand Down Expand Up @@ -573,7 +574,10 @@ void AppendEnvironmentVariableToPmiEnv(string varName, string varValue)
// Generate path to the output file
var assemblyFileName = Path.ChangeExtension(assembly.Name, ".dasm");
var dasmPath = Path.Combine(_rootPath, assembly.OutputPath, assemblyFileName);
var logPath = Path.ChangeExtension(dasmPath, ".log");

// Append a random id to the log files so they don't get picked up by "git diff"
string randomId = _rand.Next(0, 5000).ToString();
var logPath = Path.ChangeExtension(dasmPath, $".{randomId}.log");

PathUtility.EnsureParentDirectoryExists(dasmPath);

Expand Down
5 changes: 4 additions & 1 deletion src/jit-dasm/jit-dasm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,7 @@ private abstract class DisasmEngine
public bool verbose = false;
private int _errorCount = 0;
protected Dictionary<string, string> _environmentVariables;
protected Random _rand = new Random();

public int ErrorCount { get { return _errorCount; } }

Expand Down Expand Up @@ -544,7 +545,9 @@ public void GenerateAsm()

if (_rootPath != null)
{
var logPath = Path.ChangeExtension(dasmPath, ".log");
// Append a random id to the log files so they don't get picked up by "git diff"
string randomId = _rand.Next(0, 5000).ToString();
var logPath = Path.ChangeExtension(dasmPath, $".{randomId}.log");

// Redirect stdout/stderr to log file and run command.
using (var outputStreamWriter = File.CreateText(logPath))
Expand Down