| 399 | } |
| 400 | |
| 401 | func TestShortRef(t *testing.T) { |
| 402 | tests := []struct { |
| 403 | name string |
| 404 | ref string |
| 405 | want string |
| 406 | }{ |
| 407 | {name: "branch ref", ref: "refs/heads/main", want: "main"}, |
| 408 | {name: "tag ref", ref: "refs/tags/v1.0", want: "v1.0"}, |
| 409 | {name: "short name passthrough", ref: "main", want: "main"}, |
| 410 | {name: "bare SHA passthrough", ref: "abc123", want: "abc123"}, |
| 411 | {name: "empty passthrough", ref: "", want: ""}, |
| 412 | } |
| 413 | for _, tt := range tests { |
| 414 | t.Run(tt.name, func(t *testing.T) { |
| 415 | assert.Equal(t, tt.want, ShortRef(tt.ref)) |
| 416 | }) |
| 417 | } |
| 418 | } |
| 419 | |
| 420 | func TestResolveRef(t *testing.T) { |
| 421 | tests := []struct { |