Skip to content

Commit

Permalink
Merge branch 'davidalpert:main' into fix/co-authors_not_cleared_from_…
Browse files Browse the repository at this point in the history
…message_template_on_switch
  • Loading branch information
teezzan authored Oct 23, 2022
2 parents d428a3a + e3e8dac commit a2fe4c8
Show file tree
Hide file tree
Showing 4 changed files with 107 additions and 81 deletions.
6 changes: 6 additions & 0 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ on:
branches:
- main

permissions:
# contents: write
# packages: write
issues: write

jobs:
validate:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -63,4 +68,5 @@ jobs:
env:
REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
set -o pipefail
make test-features | reviewdog -name=features -fail-on-error=true -efm="cucumber %f:%l # Scenario: %m" -diff="git diff FETCH_HEAD" -filter-mode=nofilter -reporter=github-pr-check -tee
28 changes: 15 additions & 13 deletions .tools/doctor.sh
Original file line number Diff line number Diff line change
Expand Up @@ -71,21 +71,25 @@ function fix {
rm -f _fixes
inlineWarn "\nLooks like we've already tried this fix before and it's not working."
contact_support
exit
exit 1
else
echo -e "\nmaybe we can fix this...\n"
echo -e "> $*\n"
echo "$*" >>_fixes
($*)
# There needs to be some time for any util scripts to do their
# thing. 5 seconds seems to be sufficient.
sleep 5
echo -e "\n${GREEN}${BOLD}fix applied.${NORMAL}${NC}"
# Everytime we attempt a fix, there is a chance that other checks
# will be affected. Script should be re-run to ensure we are
# looking at an up to date environment.
inlineNote "\nRestarting checks to see if the problem is resolved."
(./.tools/doctor.sh) && exit
if ($*); then
# There needs to be some time for any util scripts to do their
# thing. 5 seconds seems to be sufficient.
sleep 5
echo -e "\n${GREEN}${BOLD}fix applied.${NORMAL}${NC}"
# Everytime we attempt a fix, there is a chance that other checks
# will be affected. Script should be re-run to ensure we are
# looking at an up to date environment.
inlineNote "\nRestarting checks to see if the problem is resolved."
(./.tools/doctor.sh) && exit
else
echo -e "\n${RED}${BOLD}fix failed.${NORMAL}${NC}"
exit 1
fi
fi
}

Expand Down Expand Up @@ -220,8 +224,6 @@ if [ ! -f .chglog/config.yml ]; then
git-chglog --init
fi

findCmd goreleaser "go install github.com/goreleaser/goreleaser@latest"

# if we get here clean up any incomplete fixes
rm -f _fixes

Expand Down
152 changes: 85 additions & 67 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
*** https://www.markdownguide.org/basic-syntax/#reference-style-links
-->
<!-- vale Google.Acronyms = NO -->

[![License: MIT v3][license-shield]][license-url]

<!-- vale Google.Acronyms = YES -->

<!-- [![Issues][issues-shield]][issues-url] -->
Expand Down Expand Up @@ -64,16 +66,19 @@
</details>

<!-- ABOUT THE PROJECT -->

## About the project

`git-mob` helps manage git co-authors when collaborating in real-time.

As the original authors of the node `git-mob` tool wrote:

<!-- vale off -->

> Documenting code collaboration
>
> When we work together, we should document that. It’s more than just giving credit to others, it’s also informing everyone about who was responsible for introducing changes to a codebase. Keeping a clear record of your work has lasting value - ever stumbled on an old commit only to be left with unanswered questions? In addition to explaining in your commits why a change was introduced, it also helps to document who implemented the change in case there needs to be a follow up.
<!-- vale on -->

### Why port the nodejs version to Golang?
Expand All @@ -89,15 +94,17 @@ A Golang version of `git-mob` simplifies the install and update story making thi
### What about mob.sh?

Like the original nodejs `git-mob` plugin, this golang port tool differs from and complements [`mob.sh`](https://mob.sh/) in two key ways:

- whereas `mob.sh` detects co-authors from commit messages alone, `git-mob` and `go-git-mob` understand that not all co-authors have their hands on the keyboard each session.
- whereas `mob.sh` squashes each feature branch into a single commit, `git-mob` and `go-git-mob` leave this decision up to you, complimenting your workflow by injecting conventional `Co-authored-by:` comments into each commit message through the use of a git `prepare-commit-message` hook.

### Built with

* [Golang 1.18](https://golang.org/)
* [go-releaser](https://goreleaser.com/)
- [Golang 1.18](https://golang.org/)
- [go-releaser](https://goreleaser.com/)

<!-- GETTING STARTED -->

## Getting started

### Install
Expand All @@ -121,6 +128,7 @@ if [[ ":$PATH:" == *":$(go env GOPATH)/bin:"* ]]; then echo "your path is correc
#### Pre-compiled binaries

Visit the [Releases](https://github.com/davidalpert/go-git-mob/releases) page to find binary packages pre-compiled for a variety of `GOOS` and `GOARCH` combinations:

1. Download an appropriate package for your `GOOS` and `GOARCH`;
1. Unzip it and put the binary in your path;

Expand All @@ -135,82 +143,82 @@ git-mob 0.5.1+f5536c2

### Post-install steps

1. Install helper plugins [once per machine]
1. Install helper plugins: [once per machine]

```
git mob rehash
```
```
git mob rehash
```

- The `rehash` sub-command generates simple shell scripts to make the following git plugin helpers available:
- The `rehash` sub-command generates simple shell scripts to make the following git plugin helpers available:

```
git mob-print
git mob-version
git solo
git suggest-coauthors
```
```
git mob-print
git mob-version
git solo
git suggest-coauthors
```

2. Add some co-authors
2. Add some co-authors:

```
git add-coauthor jd "Jane Doe" "jane@example.com"
```
```
git add-coauthor jd "Jane Doe" "jane@example.com"
```

3. List available co-authors
3. List available co-authors:

```
git mob --list
```
```
git mob --list
```

4. Initialize `prepare-commit-msg` hook script [once per repository]:
4. Initialize `prepare-commit-msg` hook script: [once per repository]

```
git mob init
```
```
git mob init
```

`git-mob` uses a configuration file called `~/.git-coauthors` to store available coauthors by initials
`git-mob` uses a configuration file called `~/.git-coauthors` to store available coauthors by initials.

### Add initials of the current mob to your prompt

#### Zsh with `Powerlevel10k`

1. edit the p10k configuration file
```sh
vi $POWERLEVEL9K_CONFIG_FILE
```
1. search for the example prompt function
```
prompt_example()
```
1. create a similar custom p10k prompt function to generate a mob initials prompt segment
```bash
# custom p10k prompt to print git mob member initials
function prompt_gitmob_members() {
initials=$(git mob-print --initials 2> /dev/null)
if [ ! -z "$initials" ]; then
p10k segment -f 208 -t "[$initials]"
fi
}
```
1. add the `gitmob_members` prompt segment to the `POWERLEVEL9K_LEFT_PROMPT_ELEMENTS` or `POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS` arrays
```bash
# The list of segments shown on the left. Fill it with the most important segments.
typeset -g POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(
# os_icon # os identifier
dir # current directory
vcs # git status
gitmob_members # git-mob members
prompt_char # prompt symbol
)
```
1. reload `Powerlevel10K`
```sh
. $POWERLEVEL9K_CONFIG_FILE
```
1. edit the p10k configuration file:
```sh
vi $POWERLEVEL9K_CONFIG_FILE
```
2. search for the example prompt function:
```
prompt_example()
```
3. create a similar custom p10k prompt function to generate a mob initials prompt segment:
```bash
# custom p10k prompt to print git mob member initials
function prompt_gitmob_members() {
initials=$(git mob-print --initials 2> /dev/null)
if [ ! -z "$initials" ]; then
p10k segment -f 208 -t "[$initials]"
fi
}
```
4. add the `gitmob_members` prompt segment to the `POWERLEVEL9K_LEFT_PROMPT_ELEMENTS` or `POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS` arrays:
```bash
# The list of segments shown on the left. Fill it with the most important segments.
typeset -g POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(
# os_icon # os identifier
dir # current directory
vcs # git status
gitmob_members # git-mob members
prompt_char # prompt symbol
)
```
5. reload `Powerlevel10K`:
```sh
. $POWERLEVEL9K_CONFIG_FILE
```

#### Bash

Add the initials to PS1, in `~/.bashrc`
Add the initials to PS1, in `~/.bashrc`:

```bash
function git_initials {
Expand All @@ -225,7 +233,7 @@ export PS1="\$(pwd)\$(git_initials) -> "

#### Fish

Add the following functions to `.config/fish/config.fish`
Add the following functions to `.config/fish/config.fish`:

```bash
function git_initials --description 'Print the initials for who I am currently pairing with'
Expand All @@ -244,11 +252,12 @@ end
- `git-mob` ships with an `uninstall` sub-command which cleans up and removes the top-level mob plugins and deletes itself:
```
git mob uninstall
```
```
git mob uninstall
```
<!-- USAGE EXAMPLES -->
## Usage
- TODO; coming as the project nears v1.0
Expand All @@ -261,7 +270,7 @@ end
git mob -h
```
> :warning: When requesting help make sure to use the short `-h` flag as `git` may intercept the full `--help` flag
> :warning: When requesting help make sure to use the short `-h` flag as `git` may intercept the full `--help` flag
```
$ git mob -h
Expand All @@ -280,6 +289,7 @@ Use "git-mob [command] -h" for more information about a command.
```
<!-- Troubleshooting -->
## Troubleshooting
If you run into trouble you can ask `go-git-mob` to write some diagnostics to a log file by setting the following environment variables:
Expand All @@ -291,45 +301,54 @@ If you run into trouble you can ask `go-git-mob` to write some diagnostics to a
| GITMOB_LOG_FILE | `""` | path to a log file; when empty logs go to STDOUT |
Dial up log levels to show more detail:
```
GITMOB_LOG_LEVEL=debug git commit -m "my log message"
```
Capture log messages to a file:
```
GITMOB_LOG_FILE=./mob.log GITMOB_LOG_LEVEL=debug git commit -m "my log message"
```
<!-- ROADMAP -->
## Roadmap
<!-- vale Google.Parens = NO -->
See [open issues](https://github.com/davidalpert/go-git-mob/issues) and specifically the [v1.0 - feature parity](https://github.com/davidalpert/go-git-mob/projects/1) project board for a list of known issues and up-for-grabs tasks.
<!-- vale Google.Parens = YES -->
## Contributing
See the [CONTRIBUTING](CONTRIBUTING.md) guide for local development setup and contribution guidelines.
<!-- LICENSE -->
## License
Distributed under the GPU v3 License. See [LICENSE](LICENSE) for more information.
<!-- CONTACT -->
## Contact
David Alpert - [@davidalpert](https://twitter.com/davidalpert)
Project Link: [https://github.com/davidalpert/go-git-mob](https://github.com/davidalpert/go-git-mob)
<!-- ACKNOWLEDGEMENTS -->
## Acknowledgements
* [Richard Kotze & Dennis Ideler](https://tech.findmypast.com/co-author-commits-with-git-mob/) for the [git-mob](https://github.com/rkotze/git-mob) nodejs implementation
- [Richard Kotze & Dennis Ideler](https://tech.findmypast.com/co-author-commits-with-git-mob/) for the [git-mob](https://github.com/rkotze/git-mob) nodejs implementation
<!-- MARKDOWN LINKS & IMAGES -->
<!-- https://www.markdownguide.org/basic-syntax/#reference-style-links -->
[contributors-shield]: https://img.shields.io/github/contributors/davidalpert/go-git-mob
[contributors-image-url]: https://contrib.rocks/image?repo=davidalpert/go-git-mob
[forks-shield]: https://img.shields.io/github/forks/davidalpert/go-git-mob
Expand All @@ -338,4 +357,3 @@ Project Link: [https://github.com/davidalpert/go-git-mob](https://github.com/dav
[issues-url]: https://github.com/davidalpert/go-git-mob/issues
[license-shield]: https://img.shields.io/badge/License-MIT-yellow.svg
[license-url]: https://opensource.org/licenses/MIT
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Feature: gitmessage accumulates authors over time
Feature: 🐛 gitmessage accumulates authors over time

Background:
Given I have installed git-mob into "local_bin" within the current directory
Expand Down

0 comments on commit a2fe4c8

Please sign in to comment.