mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2025-04-28 10:59:46 +00:00
Added update project commit method
This commit is contained in:
parent
3b5bcd87ea
commit
164f28e131
@ -15,6 +15,23 @@ public sealed partial class UpdateMetadataCommands
|
|||||||
await this.UpdateTauriVersion();
|
await this.UpdateTauriVersion();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async Task UpdateProjectCommitHash()
|
||||||
|
{
|
||||||
|
const int COMMIT_HASH_INDEX = 8;
|
||||||
|
|
||||||
|
var pathMetadata = Environment.GetMetadataPath();
|
||||||
|
var lines = await File.ReadAllLinesAsync(pathMetadata, Encoding.UTF8);
|
||||||
|
var currentCommitHash = lines[COMMIT_HASH_INDEX].Trim();
|
||||||
|
var headCommitHash = await this.ReadCommandOutput(Environment.GetAIStudioDirectory(), "git", "rev-parse HEAD");
|
||||||
|
var first10Chars = headCommitHash[..11];
|
||||||
|
var updatedCommitHash = $"{first10Chars}, release";
|
||||||
|
|
||||||
|
Console.WriteLine($"- Updating commit hash from '{currentCommitHash}' to '{updatedCommitHash}'.");
|
||||||
|
lines[COMMIT_HASH_INDEX] = updatedCommitHash;
|
||||||
|
|
||||||
|
await File.WriteAllLinesAsync(pathMetadata, lines, Environment.UTF8_NO_BOM);
|
||||||
|
}
|
||||||
|
|
||||||
private async Task UpdateAppVersion(PrepareAction action)
|
private async Task UpdateAppVersion(PrepareAction action)
|
||||||
{
|
{
|
||||||
const int APP_VERSION_INDEX = 0;
|
const int APP_VERSION_INDEX = 0;
|
||||||
@ -224,6 +241,28 @@ public sealed partial class UpdateMetadataCommands
|
|||||||
return matches;
|
return matches;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async Task<string> ReadCommandOutput(string workingDirectory, string program, string command)
|
||||||
|
{
|
||||||
|
var processInfo = new ProcessStartInfo
|
||||||
|
{
|
||||||
|
WorkingDirectory = workingDirectory,
|
||||||
|
FileName = program,
|
||||||
|
Arguments = command,
|
||||||
|
RedirectStandardOutput = true,
|
||||||
|
UseShellExecute = false,
|
||||||
|
CreateNoWindow = true
|
||||||
|
};
|
||||||
|
|
||||||
|
using var process = new Process();
|
||||||
|
process.StartInfo = processInfo;
|
||||||
|
process.Start();
|
||||||
|
|
||||||
|
var output = await process.StandardOutput.ReadToEndAsync();
|
||||||
|
await process.WaitForExitAsync();
|
||||||
|
|
||||||
|
return output;
|
||||||
|
}
|
||||||
|
|
||||||
private async Task IncreaseBuildNumber()
|
private async Task IncreaseBuildNumber()
|
||||||
{
|
{
|
||||||
const int BUILD_NUMBER_INDEX = 2;
|
const int BUILD_NUMBER_INDEX = 2;
|
||||||
|
Loading…
Reference in New Issue
Block a user