@@ -198,6 +198,27 @@ func TestString(t *testing.T) {
198198 },
199199 }
200200
201+ cfgWithCommitID := & config.Config {
202+ Repo : & config.RepoConfig {
203+ RequireChecks : true ,
204+ RequireApproval : true ,
205+ },
206+ User : & config.UserConfig {
207+ StatusBitsEmojis : false ,
208+ ShowCommitID : true ,
209+ },
210+ }
211+
212+ prWithHash := func (inQueue bool , commits int , hash string ) * PullRequest {
213+ return & PullRequest {
214+ InQueue : inQueue ,
215+ Commits : make ([]git.Commit , commits ),
216+ Title : "Title" ,
217+ Commit : git.Commit {CommitHash : hash },
218+ MergeStatus : PullRequestMergeStatus {},
219+ }
220+ }
221+
201222 tests := []testcase {
202223 {expect : "[?xxx] . 0 : Title" , pr : pr (true , 1 ), cfg : cfg },
203224 {expect : "[?xxx] . 0 : Title" , pr : pr (true , 2 ), cfg : cfg },
@@ -206,6 +227,12 @@ func TestString(t *testing.T) {
206227 {expect : "[?xxx] . https://github.com/testowner/testrepo/pull/0 : Title" , pr : pr (true , 1 ), cfg : cfgWithShowPRLink },
207228 // ShortPRLink: clickable short link via OSC 8
208229 {expect : "[?xxx] . \033 ]8;;https://github.com/testowner/testrepo/pull/0\033 \\ PR-0\033 ]8;;\033 \\ : Title" , pr : pr (true , 1 ), cfg : cfgWithShortPRLink },
230+ // ShowCommitID: first 8 chars of commit hash shown
231+ {expect : "[?xxx] . abcd1234 0 : Title" , pr : prWithHash (true , 1 , "abcd1234ef567890" ), cfg : cfgWithCommitID },
232+ // ShowCommitID with short hash (< 8 chars): full hash shown
233+ {expect : "[?xxx] . abcd 0 : Title" , pr : prWithHash (true , 1 , "abcd" ), cfg : cfgWithCommitID },
234+ // ShowCommitID with empty hash: no hash shown
235+ {expect : "[?xxx] . 0 : Title" , pr : prWithHash (true , 1 , "" ), cfg : cfgWithCommitID },
209236 }
210237 for i , test := range tests {
211238 assert .Equal (t , test .expect , test .pr .String (test .cfg ), fmt .Sprintf ("case %d failed" , i ))
0 commit comments