Giter Club home page Giter Club logo

koji's Introduction

🦊 koji

An interactive CLI for creating conventional commits, built on cocogitto and inspired by cz-cli.

Current Release GitHub Workflow Status Codecov Dependency Status Conventional Commits License

Commit with koji

Features

  • Create conventional commits with ease
  • Use alongside cocogitto for automatic versioning, changelog generation, and more
  • Use emoji 👋 (or, shortcodes)
  • Autocomplete for commit scope
  • Run as a git hook
  • Custom commit types

Installation

webi

curl -sS https://webinstall.dev/koji | bash

cargo

cargo install --locked koji

Be sure to have git installed first.

Usage

The basic way to use koji is as a replacement for git commit, enforcing the conventional commit standard by writing your commit through an interactive prompt.

# Do some work
cd dev/koji
git add README.md

# Commit your work
koji

See koji --help for more options.

Using as a git hook

An alternative way to use koji is as a git hook, running it any time you run git commit.

Manually

Update .git/hooks/prepare-commit-msg with the following code:

#!/bin/bash
exec < /dev/tty && koji --hook || true
npx husky add .husky/prepare-commit-msg "exec < /dev/tty && koji --hook || true

Add this to your .rusty-hook.toml:

prepare-commit-msg = "exec < /dev/tty && koji --hook || true"

Similar should work for any hook runner, just make sure you're using it with the prepare-commit-msg hook.

When using it as a hook, any message passed to git commit -m will be used for the commit summary. Writing your commit as a conventional commit, e.g. git commit -m "feat(space): delete some stars", will bypass koji altogether.

Configuration

Config values are prioritized in the following order:

  • Passed in as arguments (see: koji --help)
  • Read from file passed in via --config
  • .koji.toml in the working directory
  • ~/.config/koji/config.toml
  • The default config

Options

autocomplete

  • Type: bool
  • Optional: true
  • Description: Enables auto-complete for scope prompt via scanning commit history.
autocomplete = true

breaking-changes

  • Type: bool
  • Optional: true
  • Description: Enables breaking change prompt.
breaking_changes = true

commit-types

  • Type: Vec<CommitType>
  • Optional: true
  • Description: A list of commit types to use instead of the default.
[[commit_types]]
name = "feat"
emoji = ""
description = "A new feature"

emoji

  • Type: bool
  • Optional: true
  • Description: Prepend the commit summary with relevant emoji based on commit type.
emoji = true

issues

  • Type: bool
  • Optional: true
  • Description: Enables issue prompt, which will append a reference to an issue in the commit body.
issues = true

koji's People

Contributors

its-danny avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

koji's Issues

releases should be tagged & zipped

e.g. koji-linux-amd64-1.1.3.tar.gz

i have no idea how to do this and tbh github actions are beyond me, i just copy/paste things and hope they work.

BREAKING CHANGE footer

The breaking change prompt currently adds the ! symbol to the first line of the commit as expected.
A BREAKING CHANGE footer is optional within the spec, and I wonder if this could also be included within the prompt. Though this might require a different behaviour from the relevant prompt,

Option for --autocomplete and --emoji in config file

Is your feature request related to a problem? Please describe.

If I want to use koji directly (rather than via commit hook), then I must specify -a and -e every time I run it.

I'd prefer to be able to put this into the config file as a default and then have --no-autocomplete and --no-emoji if I need an override for the config.

(flags should always take precedence over config)

koji --hook does not handle the message from `git commit -m "msg"`

Describe the bug

I've got koji set up as a git hook:

.git/modules/installers/hooks/prepare-commit-msg

#!/bin/bash
koji --hook

When I run git commit -m "some description", it does not use the description that I gave:

app@beta ~/project> git commit -m "blah blah blah"
✔ What type of change are you committing? · feat
✔ What is the scope of this change? (press enter to skip) ·
? Write a short, imperative tense description of the change. ›

Expected behavior

When I run git commit -m "some description", koji should pre-populate the message with some description.

Ideally, I would like to be able to use git commit -m "feature(thing): something nice" or git commit -m "doc: more words" and koji suggest a fix for my spelling mistake, such as feat or docs.

Koji Errors in Submodules

Describe the bug
When running Koji in a sub module, the following error occurs:

Error: Not a directory (os error 20)

To Reproduce
Enter a sub module and run koji

Expected behavior
Koji commits to the sub module

Add `--amend` option

Is your feature request related to a problem? Please describe.
Presently koji can add new commits, but it cannot amend the last commit.

Describe the solution you'd like
koji --amend should amend the last commit.

Additional context
Each question should be pre-filled with the information coming from the last commit.

Line breaks in comment

There doesn't appear to be any way to insert a line break within a long-form comment? Is there some key combination I'm missing (noting that I'm on a Mac so this could be part of the issue) or is this not possible? If not possible then could it be added somehow?

support not needing an emoji for custom commit types

atm a custom commit type looks like this:

[[commit_types]]
name = "feat"
emoji = ""
description = "A new feature"

it should support not having the emoji line, since not everyone wants emoji in their commit messages.

Cannot enter the hash character `#`

Describe the bug
The hash character # cannot be entered.

To Reproduce
Run koji and try to enter the hash character #, either directly by typing or by copy/paste.

Additional context
I'm on Windows 10, I tried both with Git Bash and Powershell.

type to select

Is your feature request related to a problem? Please describe.

Currently when I use koji my only option to select text is to use the arrow keys. 😢

Describe the solution you'd like

If I start typing, let's say f, then feat should be selected. Or if I type d, then docs should be selected.

write more tests

everything in src/lib/ has decent test coverage. src/bin/main.rs has no tests at all because i'm not really sure how to test it. it basically comes down to figuring out how to test requestty since that's all it's doing.

Skip some questions

Is your feature request related to a problem? Please describe.
I don't write breaking changes and issues, so I want it not to ask me for them.

Describe the solution you'd like
Set on the config file like this.

breaking_change = false
issues = false

Describe alternatives you've considered
Pass these options to ignore them.

koji --no-breaking-change --no-issues

Koji does not work on M1 MacBook Pro with macOS v12.3 (21E230)

Describe the bug
The koji tool fails to run on the latest macOS. This is possibly due to dependency on OpenSSLv3.

To Reproduce
Install Koji using the following command in the terminal:
curl -sS https://webinstall.dev/koji | bash
Run koji:
koji

This problem occurs even if the release is directly downloaded from Github release page.

Expected behavior
Koji should run

Screenshots
dyld[54780]: Library not loaded: /usr/local/opt/openssl@3/lib/libssl.3.dylib
Referenced from: ~/.local/opt/koji-v1.4.0/bin/koji
Reason: tried: '/usr/local/opt/openssl@3/lib/libssl.3.dylib' (no such file), '/usr/local/lib/libssl.3.dylib' (no such file), '/usr/lib/libssl.3.dylib' (no such file)
[1] 54780 abort koji

Additional context
On macOS openssl version yields the following:
LibreSSL 2.8.3

Build problem for 1.5.2

Describe the bug
Fails to build.

To Reproduce

cargo +nightly  install-update koji
    Updating registry 'https://github.com/rust-lang/crates.io-index'

Package  Installed  Latest  Needs update
koji     v1.5.1     v1.5.2  Yes

Updating koji

...snip...

   Compiling cocogitto v5.2.0
   Compiling koji v1.5.2
error[E0061]: this function takes 7 arguments but 6 arguments were supplied
   --> /Users/berkus/.cargo/registry/src/github.com-1ecc6299db9ec823/koji-1.5.2/src/lib/commit.rs:43:15
    |
43  |     cocogitto.conventional_commit(&commit_type, scope, summary, body, None, is_breaking_change)?;
    |               ^^^^^^^^^^^^^^^^^^^-------------------------------------------------------------- an argument of type `bool` is missing
    |
note: associated function defined here
   --> /Users/berkus/.cargo/registry/src/github.com-1ecc6299db9ec823/cocogitto-5.2.0/src/lib.rs:364:12
    |
364 |     pub fn conventional_commit(
    |            ^^^^^^^^^^^^^^^^^^^
help: provide the argument
    |
43  |     cocogitto.conventional_commit(&commit_type, scope, summary, body, None, is_breaking_change, /* bool */)?;
    |                                  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Expected behavior
Builds.

Screenshots
N/A

Additional context
N/A

Cannot run on macOS

Hello, I downloaded and want to try your tool on my macBook Air but I cannot run it:
Screenshot 2023-11-28 at 17 25 09

windows version missing

Hey,

I had 1.2.0 installed and there was a windows version but after that version you changed the publish process and you don't built windows anymore.

Is there a limitation or something like that, why you don't provide it anymore.

Video showcase ?

Hey @its-danny I am writing docs for cocogitto's next release, I was wondering, what tool did you use to make the video on koji's readme ?

release on crates.io

i've never released anything there, so not sure how it works. but you should be able to use koji by having it as a dev dependency.

Error with cocogitto git-hooks

Describe the bug
Running Koji with a hook installed by cocogitto results in the error:

Error: failed to parse config cause unknown field 'git_hooks', expected one of 'from_latest_tag', 'ignore_merge_commits', 'monorepo_version_separator', 'branch_whitelist', 'tag_prefix', 'pre_bump_hooks', 'post_bump_hooks', 'pre_package_bump_hooks', 'post_package_bump_hooks', 'commit_types', 'changelog', 'bump_profiles', 'packages'

To Reproduce
create a cog.toml with the following content:

[git_hooks.commit-msg]
script = """#!/bin/bash

set -e

cog verify --file ${1}
"""

run
cog install-hook --all

in the same repo run koji

Expected behavior
koji commits the message and cog verify passes.

Additional context
I have no idea if this is a cocogitto issue or a koji issue. Committing without koji works fine.

Koji requires GPG

Describe the bug
When I run koji, it requires GPG.

thread 'main' panicked at 'error calling gpg command, is gpg installed ?: Os { code: 2, kind: NotFound, message: "No such file or directory" }', /Users/runner/.cargo/registry/src/github.com-1ecc6299db9ec823/cocogitto-5.2.0/src/git/commit.rs:86:10
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

To Reproduce
To run the command on a machine doesn't have GPG.

Expected behavior
Ignore GPG if not installed.

Additional context
Is it not an issue of koji, but of cocogitto?
I usually sign off commits with SSH not GPG.

Fails to build with cocogitto

Describe the bug

Fails to build with latest cocogitto:

   Compiling cocogitto v6.1.0
   Compiling koji v2.2.0
error[E0061]: this method takes 1 argument but 7 arguments were supplied
  --> /Users/berkus/.cargo/registry/src/index.crates.io-6f17d22bba15001f/koji-2.2.0/src/lib/commit.rs:44:15
   |
44 |     cocogitto.conventional_commit(
   |               ^^^^^^^^^^^^^^^^^^^
45 |         &commit_type,
   |         ------------ expected `CommitOptions<'_>`, found `&String`
   |
note: method defined here
  --> /Users/berkus/.cargo/registry/src/index.crates.io-6f17d22bba15001f/cocogitto-6.1.0/src/command/commit.rs:24:12
   |
24 |     pub fn conventional_commit(&self, opts: CommitOptions) -> Result<()> {
   |            ^^^^^^^^^^^^^^^^^^^
help: remove the extra arguments
   |
45 -         &commit_type,
45 +         /* CommitOptions<'_> */,
   |

For more information about this error, try `rustc --explain E0061`.
error: could not compile `koji` (lib) due to 1 previous error

To Reproduce

cargo +nightly install koji

Expected behavior

Koji should install.

Additional context

Not sure when cocogitto changed this interface, but it seems like they broke API between 6.0 and 6.1. Koji should probably depend strictly on 6.0 or upgrade the dep to 6.1.

Cannot --version from HOME directory

Describe the bug

koji --version
Error: could not find repository from '/Users/aj'; class=Repository (6); code=NotFound (-3)

Expected behavior

Should be able to print version from any directory, not just from project directories with a .git.

next release

A lot of issues were closed, so I'd like to do a new release. Main issue is the whole release flow is confusing and kind of busted, so I need to update that. Important part is that it creates releases for all platforms (and they work).

Also need to clean the README up to be easier to read and less scattered.

Afterwards, open a PR at webinstall to update the koji installer (+ README).

cache scopes

config file needs to change to accept a scopes array. on first run (with --autocomplete), save the found scopes to the config via appending it. this allows the user to set up their own list when starting a fresh repo, while also populating it with new ones. every time you commit with koji, the list should be updated.

for this to work, commit_types needs to work differently. when we load a config, we need to check for commit_types and use the default if they don't exist. currently we only use the default if a config file doesn't exist at all.

this sounds like the correct thing to do, but i'm no totally sure it's necessary. autocomplete is an optional flag, and in a large repo it only slows startup down by milliseconds.

Look for toml in user config directory, or .kojirc.toml in the git directory

Is your feature request related to a problem? Please describe.

First

Most config files for tooling begin with . and end in rc.<ext>:

  • .jshintrc
  • .eslintrc.json
  • .prettierrc.json

I would prefer that koji.toml follow this convention.

Second

Most tools allow for a top-level config file in ~/.config/<name>/config.<ext>.

It would be great if koji would do this as a fallback.

For example, if I don't have a local .kojirc.toml in my git directory, but I have one in ~/.config/koji/config.toml, then that should be used instead.

Does not work with git modules

Error: Not a directory (os error 20)

Describe the bug

If you're working directory is a git submodule, then .git will be a text file with the parameter gitdir acting as a (sym)link to the real module directory.

.git:

gitdir: ../.git/modules/installers
app@beta ~/project> git commit
✔ What type of change are you committing? · docs
✔ What is the scope of this change? (press enter to skip) · koji
✔ Write a short, imperative tense description of the change. · update docs for webi users as target audience
✔ Provide a longer description of the change. (press enter to skip) ·
✔ Are there any breaking changes? · No
✔ Does this change affect any open issues? · No
Error: Not a directory (os error 20)

Use custom commit types from cog.toml

Is your feature request related to a problem? Please describe.

Hi, I really like your work on this project so far, but there's one thing that keeps me from using it regularly: It doesn't take the custom commit types I've configured in cog.toml, the configuration file from cocogitto, but requires another config file, with often the exact same entries.

Describe the solution you'd like

I'd like koji to parse the custom commit types I configured in cog.toml, perhaps specified through a configuration option (like "parse custom commit types from the cog.toml in the current repository if available").

Describe alternatives you've considered

None.

Additional context

Obviously, the description that's configurable through kojis configuration file would be missing from the commit types declared in cog.toml. I thought of 3 ways to solve this. The first one is to just use the changelog_title property which should be available on every declared commit type. The second one is to omit it all together and just have it say "Custom type declared in cog.toml" or similar. The last one, which can be used together with the first two proposals, is to advice users to add a description (or similarly named) property to their commit types, which would just be ignored by cocogitto but could be used by koji.

As it's currently not possible to remove a commit type in cocogitto, the current descriptions in koji can still be re-used in my opinion, only non-standard custom commit types would need to be handled differently.
Edit: I opened a PR on cocogitto to allow disabling default commit types. If this is ever implemented, koji should also allow disabling commit types in the same way as cocogitto, provided that this PR will be implemented until then. cocogitto/cocogitto#386

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.