Skip to content

Commit

Permalink
Have About dialog copy full Git commit hash to clipboard
Browse files Browse the repository at this point in the history
and use full hash in GitHub web app URI
  • Loading branch information
YoshiRulz committed Jun 19, 2024
1 parent e5dc04d commit 3490b54
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public void Execute(GeneratorExecutionContext context)

var rev = ExecuteGitWithArguments($"-C {projectDir} rev-list HEAD --count") ?? string.Empty;
var branch = ExecuteGitWithArguments($"-C {projectDir} rev-parse --abbrev-ref HEAD") ?? "master";
var shortHash = ExecuteGitWithArguments($"-C {projectDir} log -1 --format=\"%h\"") ?? "000000000";
var hash = ExecuteGitWithArguments($"-C {projectDir} log -1 --format=\"%H\"") ?? "0000000000000000000000000000000000000000";

// Generated source code
string source = $@"namespace BizHawk.Common
Expand All @@ -58,7 +58,8 @@ public static partial class VersionInfo
{{
public const string SVN_REV = ""{rev}"";
public const string GIT_BRANCH = ""{branch}"";
public const string GIT_SHORTHASH = ""{shortHash}"";
public const string GIT_HASH = ""{hash}"";
public const string GIT_SHORTHASH = ""{hash.Substring(startIndex: 0, length: 9)}"";
}}
}}
";
Expand Down
Binary file modified References/BizHawk.SrcGen.VersionInfo.dll
Binary file not shown.
4 changes: 1 addition & 3 deletions src/BizHawk.Client.EmuHawk/BizBox.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,7 @@ private void linkLabel2_LinkClicked(object sender, LinkLabelLinkClickedEventArgs
=> Process.Start((string) ((Control) sender).Tag);

private void btnCopyHash_Click(object sender, EventArgs e)
{
Clipboard.SetText(VersionInfo.GIT_SHORTHASH);
}
=> Clipboard.SetText(VersionInfo.GIT_HASH);

private void linkLabel3_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
=> Process.Start(VersionInfo.BizHawkContributorsListURI);
Expand Down
2 changes: 1 addition & 1 deletion src/BizHawk.Common/VersionInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ static VersionInfo()
}

public static (string Label, string TargetURI) GetGitCommitLink()
=> ($"Commit :{GIT_BRANCH}@{GIT_SHORTHASH}", $"https://github.com/TASEmulators/BizHawk/commit/{GIT_SHORTHASH}");
=> ($"Commit :{GIT_BRANCH}@{GIT_SHORTHASH}", $"https://github.com/TASEmulators/BizHawk/commit/{GIT_HASH}");

public static string GetFullVersionDetails()
{
Expand Down

0 comments on commit 3490b54

Please sign in to comment.