jvanbruegge / commithelper Goto Github PK
View Code? Open in Web Editor NEWA tool to create and lint commit messages
License: MIT License
A tool to create and lint commit messages
License: MIT License
Hi Jan Van,
I liked your project and am using it to create standardized rules for the company I work for. Being able to use the same rules on the 'prepare-commit-msg' and 'commit-msg' hooks is very good.
One question I have is:
Is it possible to use the 'prompt' part via CLI, the same as when running 'npx git-cz'?
I'm trying to use via CLI and just display the message in the terminal, I tried setting '--file' to .'git/COMMIT_EDITMSG' without success.
I would like to be able to run via CLI and continue using also on the 2 hooks I mentioned.
If you have any north I can help you in PR.
Similar to the config's types
, it would be great to have a message. Something like:
interface Scope {
name: string;
message: string;
}
interface Config {
// ...
scopes: Scope[];
// ...
}
That way, it will be easier for new project contributors to check what each scope
is for when using prompt
mode.
Edit:
I'm not familiar with io-ts
so I don't know if this is the correct approach on how to do this:
const ScopeNameOnly = t.string;
export type ScopeNameOnly = t.TypeOf<typeof ScopeNameOnly>;
export function isScopeNameOnly(scopes: Scope[]): boolean {
return ScopeNameOnly.is(scopes[0]);
}
const ScopeWithMessage = t.type({
name: t.string,
message: t.string,
});
export type ScopeWithMessage = t.TypeOf<typeof ScopeWithMessage>;
export function isScopeWithMessage(scopes: Scope[]): boolean {
return ScopeWithMessage.is(scopes[0]);
}
/** This way, Scope can still support the basic string[] for backwards compatibility. */
const Scope = t.union([ScopeNameOnly, ScopeWithMessage]);
export type Scope = t.TypeOf<typeof Scope>; // Should be (string|{name:string,message:string})[].
Then getScopes(type: string, config: Config): Scope[]
can transform the basic ScopeNameOnly[]
to ScopeWithMessage[]
.
Hi, sorry for filing another ticket. I'd be happy to send a PR if that's okay.
I've set commithelper.allowCustomScopes
to true
. However, this input-type question is not triggered when selecting custom
as a scope:
// prompt.ts
{
type: 'input',
name: 'scope',
message: 'Enter a custom scope:',
when: answers => answers.scope === 'custom',
},
$ pnpm commit
? Select the type of change that you're committing: feat: A new feature
? What is the scope of this change (e.g. component or file name): custom
? Write a short, imperative tense description of the change (max 87 chars):
(0)
$ pnpm commit
? Select the type of change that you're committing: feat: A new feature
? What is the scope of this change (e.g. component or file name): custom
? Enter a custom scope: my-custom-scope
? Write a short, imperative tense description of the change (max 78 chars):
(0)
"commithelper": {
// ...
"allowCustomScopes": true,
// ...
},
There are 2 questions with the name
of scope
and it looks like it's clashing with each other.
// prompt.ts
{
type: 'list',
name: 'scope',
message: `What is the scope of this change (e.g. component or file name):`,
choices: getChoices(config),
when: answers => getChoices(config)(answers).length > 0,
},
{
type: 'input',
name: 'scope',
message: 'Enter a custom scope:',
when: answers => answers.scope === 'custom',
},
The second one can be changed to customScope
. Afterwards, the rest of the code can be updated accordingly:
// prompt.ts
{
type: 'input',
name: 'customScope',
message: 'Enter a custom scope:',
when: answers => answers.scope === 'custom',
},
// message.ts
export interface Message {
type: string;
scope?: string;
customScope?: string;
subject: string;
body?: string;
breaking?: string;
issuesClosed?: string;
}
// Update the rest of the code.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.