Skip to content

Commit

Permalink
feat(options): New option for ticket title (#96)
Browse files Browse the repository at this point in the history
  • Loading branch information
mike-minchenko authored Apr 18, 2024
1 parent 3c6cc55 commit 6b93cb6
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ Expand to see explanations and possible values
| `check_ticket.add_to_title` | If true add ticket to title |
| `check_ticket.append_hashtag` | **Deprecated**: see prepend_hashtag |
| `check_ticket.prepend_hashtag` | "Never" (default), "Prompt", or "Always" |
| `check_ticket.title_position` | "start" (of description) (default), "end", "before-colon" |
| `check_ticket.title_position` | "start" (of description) (default), "end", "before-colon", "beginning" (of the entire commit title) |
| `check_ticket.surround` | "" (default), "[]", "()", "{}" - Wraps ticket in title |
| `commit_title.max_size` | Max size of title including scope, type, etc... |
| `commit_body.enable` | If true include body |
Expand Down
6 changes: 5 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,11 @@ function build_commit_string(commit_state: z.infer<typeof CommitState>,
const close_token = surround.charAt(1);
title_ticket = `${open_token}${commit_state.ticket}${close_token}`
}

const position_beginning = config.check_ticket.title_position === 'beginning';
if (title_ticket && config.check_ticket.add_to_title && position_beginning) {
commit_string = `${colorize ? color.magenta(title_ticket) : title_ticket} ${commit_string}`;
}

const position_before_colon = config.check_ticket.title_position === "before-colon"
if (title_ticket && config.check_ticket.add_to_title && position_before_colon) {
Expand Down Expand Up @@ -343,4 +348,3 @@ function build_commit_string(commit_state: z.infer<typeof CommitState>,

return commit_string;
}

2 changes: 1 addition & 1 deletion src/zod-state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ export const Config = z
append_hashtag: z.boolean().default(false),
prepend_hashtag: z.enum(['Never', 'Always', 'Prompt']).default("Never"),
surround: z.enum(["", "()", "[]", "{}"]).default(""),
title_position: z.enum(["start", "end", "before-colon"]).default("start"),
title_position: z.enum(["start", "end", "before-colon", "beginning"]).default("start"),
})
.default({}),
commit_title: z
Expand Down

0 comments on commit 6b93cb6

Please sign in to comment.