• Stars
    star
    1,347
  • Rank 33,765 (Top 0.7 %)
  • Language
    TypeScript
  • License
    MIT License
  • Created over 3 years ago
  • Updated almost 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

πŸ™‰ πŸ“£ Communicate important updates to your team via git commit messages

git-notify

Communicate important updates to your team via git commit messages.

What is git-notify?

Sometimes you need to communicate changes to other developers on your project. In a small team, a Slack message works okay, but in larger teams and distributed organizations (such as open source projects), reaching everyone can be a pain.

git-notify allows you to embed announcements into your git commit messages:

git commit -m 'git-notify: NEW DEVELOPMENT ENVIRONMENT ...'

And display them to another developer on a machine, far far away:

Demo

Simple as that.

How to use git-notify?

Just add "git-notify:" to your git commit message, and anything that follows will be displayed when another developer pulls that commit, or switches from a branch that does not contain that commit to one that does.

If you're using a merge or squash commit strategy on GitHub, you can also add them to the extended commit message when landing a PR:

GitHub PR flow example

Getting Started

Install git-notify to your npm (or yarn) based project as a devDependency:

# using npm
npm install --save-dev git-notify

# using yarn
yarn add -D git-notify

Next, we'll configure git-notify to run automatically when other developers pull commits that contain git messages. Below we show how to achieve this with the excellent husky library. For other approaches, see the Git Hooks section later in this document.

Installing hooks with husky

# using npm
npm install --save-dev husky@4

# using yarn
yarn add -D husky@4

Configure git-notify hooks by adding the following husky entries to your package.json:

{
  //...snip
  "husky": {
    "hooks": {
      "post-merge": "git-notify merge $HUSKY_GIT_PARAMS",
      "post-rewrite": "git-notify rewrite $HUSKY_GIT_PARAMS",
      "post-checkout": "git-notify checkout $HUSKY_GIT_PARAMS"
    }
  }
}

Note: The above instructions below are for husky v4.x. Husky v5 has changed how hooks are configured, as well updated its licensing terms to be free only to other open source projects.See husky's own documentation for how to configure hooks in their latest version.

Configuration

  • git-notify --prefix "@everyone"
    • Change the prefix git-notify looks for in git commit messages
    • Default: git-notify:
  • git-notify --color "#ff6f6f"
    • Change the color of the banner or message
    • This can be one of the chalk preset colors or a hex value. Note that not all terminals support full hex color scales.
  • git-notify --simple
    • Instead of a fancy banner, displays a simple text message

All parameters

Run npx git-notify --help for an up to date list of parameters:

npx git-notify --help

  Usage
    $ git-notify <method> [options] $GIT_PARAMS

   Methods
     since <commit>  show all notifications since commit
     merge           run on git pull/merge
     rewrite         run on git rebase
     checkout        run on git checkout/switch

  Options
     --prefix, -p    prefix to  look for in commit messages (default: "git-notify:")
     --simple, -s    show a plain, unboxed notification
     --color, -c     color of displayed notification

  Examples
     $ git-notify since HEAD~5
     $ git-notify checkout $GIT_PARAMS

About formatting

git-notify will display a message for every "git-notify:" prefix it finds in the commit log that was just pulled/merged/rebased/checked out. The notification message will be the rest of the paragraph following the prefix.

For example, this commit message:

This change upgrades some of our dependencies. git-notify: Please run npm install

Will print:

            ╒════════════════════════════╕
            β”‚                            β”‚
            β”‚  Please run npm install    β”‚
            β”‚                            β”‚
            β•˜β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•›

The message will run until the end of the paragraph, delimited by a double line break. Single line breaks and other whitespace will be preserved. So that:

Rewrite everything.

git-notify:EVERYTHING HAS CHANGED
This project has been rewritten
from scratch. If something broke,
please contact Jeff at [email protected].

May god please forgive me.

Will display:

         ╒══════════════════════════════════════════╕
         β”‚                                          β”‚
         β”‚          EVERYTHING HAS CHANGED          β”‚
         β”‚     This project has been rewritten      β”‚
         β”‚    from scratch. If something broke,     β”‚
         β”‚   please contact Jeff at [email protected].   β”‚
         β”‚                                          β”‚
         β•˜β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•›

You can run git-notify since to test configuration and dry-run the message you've just created locally. For example:

git commit -m '@team what's up??'
npx git-notify since HEAD~1 --prefix "@team"

Can I group messages

Not at the moment, but this should not be difficult to add. See Contributing

Git Hooks

Installing with husky

See Installing hooks with husky in the Getting Started section.

Installing hooks by any other means

git-notify is agnostic to however you want to install your git hooks.

The hooks you need to configure are:

  • post-merge (runs on git pull and git merge)
    • npx git-notify merge $GIT_PARAMS
  • post-rewrite (runs on git rebase)
    • npx git-notify rewrite $GIT_PARAMS
  • post-checkout (runs on git checkout -- optional, but useful)
    • npx git-notify checkout $GIT_PARAMS

At the time of writing, git-notify checkout is the only hook that uses the arguments ($GIT_PARAMS) passed to the git hook, but ideally you should always pass the arguments to git-notify, in case we'll need to use them in a later version.

See githooks.com for more resources on the topic. Documentation for different approaches are welcome!

Installing git-notify without npm

At this time, git-notify is a node-based project. While I recognize it could be useful in other types of projects (ruby, python, rust, etc...), cross-platform scripting sucks, and this project is not interested in solving those problems at this time.

However, the git-notify beviour has been implemented in other languages:

If you like this idea, feel free to steal it and implement your own version, and I'll add it here.

Contributing

This project is open to contributions. For anything that would radically change the nature of the project or increase its maintenance burden, please open an issue first to discuss.

Local development

This project is written in TypeScript and scaffolded using tsdx.

To run TSDX, use:

yarn start

This builds to /dist and runs the project in watch mode so any edits you save inside src causes a rebuild to /dist.

To do a one-off build, use npm run build or yarn build.

To run tests, use npm test or yarn test.

Thanks

Special thanks to Sindre Sorhus, whose excellent meow, boxen and chalk libraries make developing Node CLIs a breeze.

LICENSE

MIT

More Repositories

1

jest-clean-console-reporter

A Jest Reporter to group, hide and prettify spammy console warnings
JavaScript
543
star
2

vscode-hacker-typer

Great for live coding presentations, impressing your friends, or just trying to look busy at work.
TypeScript
446
star
3

react-native-chat-tutorial

A step-by-step tutorial to create your own Chat app with React Native
JavaScript
275
star
4

css-properly

Write CSS Properly πŸ‡¬πŸ‡§πŸ§
JavaScript
234
star
5

vscode-live-frame

Run your web app inside VS Code
TypeScript
205
star
6

react-native-reversed-flat-list

[DEPRECATED] A reversed React Native FlatList, useful for creating performant bottom-anchored lists for chats and whatnot
JavaScript
135
star
7

NaNoWriMo

Wallet - A Novel for National Novel Writing Month 2018
JavaScript
28
star
8

is-it-over

It's so over. No wait, we're back.
TypeScript
27
star
9

redux-offline-example

β˜• Something brewin' here. Come back next week.
JavaScript
19
star
10

react-native-animated-playground

Shared transitions with React Native Animated
JavaScript
17
star
11

react-native-snap-demo

A "Snapchat" demo app for React Native for Beginners course
JavaScript
13
star
12

cloudflare-pages-react-sqlite-starter

Vite on Cloudflare Pages
TypeScript
11
star
13

cycle-react-native-example

Sample application for using Cycle.js with React Native (CycleConf 2016)
JavaScript
10
star
14

react-native-training-chat-server

A client library for a chat server to be used in React Native training
JavaScript
9
star
15

jevakallio.dev

My personal website
HTML
7
star
16

SharedTransitions

Experiments with React Native shared element transitions
JavaScript
6
star
17

hello-worker

Experimenting with CloudFlare Workers and Durable Objects. Nothing to see here.
Shell
6
star
18

crna-pull-request-preview

Deprecated. Go to: https://github.com/FormidableLabs/appr
JavaScript
6
star
19

react-derivable-tools

Utilities for using DerivableJS with React
JavaScript
6
star
20

needly

A tiny JavaScript dependency injector / service locator
JavaScript
4
star
21

habbit

Old habits die hard. These birds just keep dying.
TypeScript
4
star
22

jargon-of-the-day

3
star
23

react-native-snap-camera

A Camera component for React Native For Beginners course
JavaScript
2
star
24

restless-london

RESTless London Meetup website
JavaScript
2
star
25

victory-composed

Ready-made composed Victory components
JavaScript
2
star
26

react-native-snap-drag

Building blocks for React Native For Beginners course
JavaScript
2
star
27

foamblog

Open Foam
HTML
1
star
28

hidden-helsinki

JavaScript
1
star
29

foam-launcher

Just prototyping. Nothing to see here
JavaScript
1
star
30

party-daemons

Partykit Implementation of AI Daemons
TypeScript
1
star
31

kallio-prototype

Protoype for Helsinki-based city adventure game
JavaScript
1
star
32

pepperoni-hackathon-app

JavaScript
1
star
33

partyflags

WIP
TypeScript
1
star
34

partykit-onfetch-routing

Example of using PartyKit onFetch to do dynamic routing to rooms using cookies
TypeScript
1
star
35

foam

A personal knowledge management and sharing system for VSCode
TypeScript
1
star