From dfd9e72b1786597db643d50c7a55d1fcbadf7802 Mon Sep 17 00:00:00 2001 From: nsfisis Date: Sun, 30 Aug 2026 16:24:31 +0900 Subject: build(nix): add a package output producing the binary Co-Authored-By: Claude Opus 5 --- scripts/linters/lint | 2 + scripts/linters/src/Linters/ComposerPin.php | 63 +++++++++++++++++++++++++++++ 2 files changed, 65 insertions(+) create mode 100644 scripts/linters/src/Linters/ComposerPin.php (limited to 'scripts') diff --git a/scripts/linters/lint b/scripts/linters/lint index 150e1f1a..7e7c5fe6 100755 --- a/scripts/linters/lint +++ b/scripts/linters/lint @@ -6,6 +6,7 @@ declare(strict_types=1); require __DIR__ . '/vendor/autoload.php'; use Shirabe\Lint\Linters\CargoWorkspaceDependencies; +use Shirabe\Lint\Linters\ComposerPin; use Shirabe\Lint\Linters\ContiguousUseBlock; use Shirabe\Lint\Linters\NoBannedUse; use Shirabe\Lint\Linters\NoDecorativeSectionComment; @@ -24,6 +25,7 @@ $rootDir = dirname(__DIR__, 2); $runner = new Runner($rootDir, [ [new CargoWorkspaceDependencies(), []], + [new ComposerPin(), []], [new ContiguousUseBlock(), []], [new NoBannedUse(), []], [new NoDecorativeSectionComment(), [ diff --git a/scripts/linters/src/Linters/ComposerPin.php b/scripts/linters/src/Linters/ComposerPin.php new file mode 100644 index 00000000..d1db55fe --- /dev/null +++ b/scripts/linters/src/Linters/ComposerPin.php @@ -0,0 +1,63 @@ +submoduleRev($rootDir); + $inputRev = $this->inputRev($rootDir); + + if ($submoduleRev === $inputRev) { + return []; + } + + return [ + "submodule: {$submoduleRev}", + "flake input: {$inputRev}", + ]; + } + + private function submoduleRev(string $rootDir): string + { + $command = sprintf('git -C %s ls-tree HEAD composer', escapeshellarg($rootDir)); + exec($command, $output, $status); + if ($status !== 0 || $output === []) { + return '(unreadable: git ls-tree HEAD composer failed)'; + } + + // ` commit \tcomposer` + $fields = preg_split('/\s+/', $output[0]); + + return $fields[2] ?? '(unreadable: unexpected git ls-tree output)'; + } + + private function inputRev(string $rootDir): string + { + $lock = json_decode((string) file_get_contents("{$rootDir}/flake.lock"), true); + + return $lock['nodes']['composer']['locked']['rev'] ?? '(missing from flake.lock)'; + } +} -- cgit v1.3.1-4-g156e