@@ -4,6 +4,7 @@ import { tmpdir } from "node:os";
44import { join } from "node:path" ;
55import { afterAll , beforeAll , describe , expect , it } from "vitest" ;
66import {
7+ assertGitAvailable ,
78 buildPathspecArgs ,
89 ensureCommitAvailable ,
910 extractBranchName ,
@@ -745,3 +746,35 @@ describe("merge commit handling", () => {
745746 } ) ;
746747 } ) ;
747748} ) ;
749+
750+ describe ( "assertGitAvailable" , ( ) => {
751+ it ( "succeeds inside a git repository with git on PATH" , ( ) => {
752+ const repo = createTempRepo ( ) ;
753+ try {
754+ expect ( ( ) => assertGitAvailable ( repo . cwd ) ) . not . toThrow ( ) ;
755+ } finally {
756+ rmSync ( repo . cwd , { recursive : true , force : true } ) ;
757+ }
758+ } ) ;
759+
760+ it ( "throws when not inside a git repository" , ( ) => {
761+ const cwd = mkdtempSync ( join ( tmpdir ( ) , "linear-release-no-repo-" ) ) ;
762+ try {
763+ expect ( ( ) => assertGitAvailable ( cwd ) ) . toThrow ( / g i t r e p o s i t o r y / ) ;
764+ } finally {
765+ rmSync ( cwd , { recursive : true , force : true } ) ;
766+ }
767+ } ) ;
768+
769+ it ( "throws with a PATH hint when the git binary is missing" , ( ) => {
770+ const repo = createTempRepo ( ) ;
771+ const originalPath = process . env . PATH ;
772+ process . env . PATH = "/nonexistent-linear-release-test-dir" ;
773+ try {
774+ expect ( ( ) => assertGitAvailable ( repo . cwd ) ) . toThrow ( / g i t .* o n P A T H / ) ;
775+ } finally {
776+ process . env . PATH = originalPath ;
777+ rmSync ( repo . cwd , { recursive : true , force : true } ) ;
778+ }
779+ } ) ;
780+ } ) ;
0 commit comments