Skip to content

Show help if commit message is not provided#17

Merged
sbimochan merged 2 commits intosbimochan:masterfrom
mesaugat:help
Jan 16, 2019
Merged

Show help if commit message is not provided#17
sbimochan merged 2 commits intosbimochan:masterfrom
mesaugat:help

Conversation

@mesaugat
Copy link
Copy Markdown
Contributor

@mesaugat mesaugat commented Jan 15, 2019

Bonus:

  commit -h
  commit --help

will do the same.

Output:

Create a commit prefixed with the current branch name.

Usage:
  commit MESSAGE

Example:
  commit "Initial commit"

Also, stick with bash conventions.

Bonus:
  commit -h
  commit --help

will do the same.
Comment thread commit
#!/usr/bin/env bash
set -euo pipefail

if [ -z "${1:-}" ] || [ "$1" = "-h" ] || [ "$1" = "--help" ]; then
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On second thought, this and set -euo pipefail will break the empty git commit command which is useful when writing a long commit message. It opens an editor for such commits when we don't provide the -m flag.

@sbimochan sbimochan merged commit 44205dc into sbimochan:master Jan 16, 2019
@mesaugat mesaugat deleted the help branch January 16, 2019 05:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants