Commit 4fb32c1e authored by Mark Tyneway's avatar Mark Tyneway Committed by GitHub

contracts-bedrock: log the commit hash in deploy script (#10369)

Ensures that the commit hash is logged as part of
the deploy script's execution so its easier to help
debug issues with it.
parent 23a628b6
......@@ -5,6 +5,8 @@ import { Script } from "forge-std/Script.sol";
import { Artifacts } from "scripts/Artifacts.s.sol";
import { Config } from "scripts/Config.sol";
import { DeployConfig } from "scripts/DeployConfig.s.sol";
import { Executables } from "scripts/Executables.sol";
import { console } from "forge-std/console.sol";
/// @title Deployer
/// @author tynes
......@@ -17,6 +19,8 @@ abstract contract Deployer is Script, Artifacts {
function setUp() public virtual override {
Artifacts.setUp();
console.log("Commit hash: %s", Executables.gitCommitHash());
vm.etch(address(cfg), vm.getDeployedCode("DeployConfig.s.sol:DeployConfig"));
vm.label(address(cfg), "DeployConfig");
vm.allowCheatcodes(address(cfg));
......
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import { Vm } from "forge-std/Vm.sol";
/// @notice The executables used in ffi commands. These are set here
/// to have a single source of truth in case absolute paths
/// need to be used.
library Executables {
/// @notice Foundry cheatcode VM.
Vm private constant vm = Vm(address(uint160(uint256(keccak256("hevm cheat code")))));
string internal constant bash = "bash";
string internal constant jq = "jq";
string internal constant forge = "forge";
......@@ -12,4 +16,14 @@ library Executables {
string internal constant sed = "sed";
string internal constant find = "find";
string internal constant ls = "ls";
string internal constant git = "git";
/// @notice Returns the commit hash of HEAD.
function gitCommitHash() internal returns (string memory) {
string[] memory commands = new string[](3);
commands[0] = bash;
commands[1] = "-c";
commands[2] = "git rev-parse HEAD";
return string(vm.ffi(commands));
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment