Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/purplebooth/git-moves-together
Spot coupling by finding out which files are always in the same commit
https://github.com/purplebooth/git-moves-together
cli coupling dev-tools git
Last synced: 3 months ago
JSON representation
Spot coupling by finding out which files are always in the same commit
- Host: GitHub
- URL: https://github.com/purplebooth/git-moves-together
- Owner: PurpleBooth
- License: cc0-1.0
- Created: 2021-08-27T12:41:52.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2024-09-07T18:05:59.000Z (6 months ago)
- Last Synced: 2024-09-08T08:41:06.544Z (6 months ago)
- Topics: cli, coupling, dev-tools, git
- Language: Rust
- Homepage:
- Size: 324 KB
- Stars: 14
- Watchers: 4
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.md
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# git moves-together
This tells you when files in the repository frequently move together.
This lets you identify where the coupling is in the system. Coupling is
negative and to an extent unavoidable, this tool aims to make it
visible.## Getting Started
If every time I commit no file moves at the same time, that's 0 coupling
``` shell,script(name="no-coupling-setup",expected_exit_code=0)
echo "no-coupling-setup - file_1" > file_1
git add .
git commit --message "demo: no-coupling-setup"
echo "no-coupling-setup - file_2" > file_2
git add .
git commit --message "demo: no-coupling-setup"
```When we run git-moves-together we can see that these files have no
direct commit based coupling``` shell,script(name="no-coupling",expected_exit_code=0)
git-moves-together
`````` text,verify(script_name="no-coupling",stream=stdout)
0 files move together
```If we then make a change to both files in the same commit
``` shell,script(name="coupling-setup",expected_exit_code=0)
echo "coupling-setup - file_1" > file_1
echo "coupling-setup - file_2" > file_2
echo "coupling-setup - file_3" > file_3
git add .
git commit --message "demo: coupling-setup"
```When we run git-moves-together we can see that these files have no
direct commit based coupling``` shell,script(name="coupling",expected_exit_code=0)
git-moves-together $PWD
`````` text,verify(script_name="coupling",stream=stdout)
╭──────────────────┬──────────────────┬────────────┬──────────┬─────────╮
│ File A ┆ File B ┆ Together % ┆ Together ┆ Commits │
╞══════════════════╪══════════════════╪════════════╪══════════╪═════════╡
│ some-repo@file_1 ┆ some-repo@file_2 ┆ 50.00% ┆ 1 ┆ 2 │
├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌┤
│ some-repo@file_1 ┆ some-repo@file_3 ┆ 100.00% ┆ 1 ┆ 1 │
├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌┤
│ some-repo@file_2 ┆ some-repo@file_3 ┆ 50.00% ┆ 1 ┆ 2 │
╰──────────────────┴──────────────────┴────────────┴──────────┴─────────╯
```You can also reduce the commits you're including, by limiting the
changes to a specific time period``` shell,script(name="day-limit-setup",expected_exit_code=0)
echo "day-limit-setup - file_1" > file_1
git add .
GIT_COMMITTER_DATE="2005-04-07T22:13:13" git commit --message "demo: day-limit-setup"
`````` shell,script(name="day-limit",expected_exit_code=0)
git-moves-together -d 30 $PWD
`````` text,verify(script_name="day-limit",stream=stdout)
╭──────────────────┬──────────────────┬────────────┬──────────┬─────────╮
│ File A ┆ File B ┆ Together % ┆ Together ┆ Commits │
╞══════════════════╪══════════════════╪════════════╪══════════╪═════════╡
│ some-repo@file_1 ┆ some-repo@file_2 ┆ 50.00% ┆ 1 ┆ 2 │
├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌┤
│ some-repo@file_1 ┆ some-repo@file_3 ┆ 100.00% ┆ 1 ┆ 1 │
├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌┤
│ some-repo@file_2 ┆ some-repo@file_3 ┆ 50.00% ┆ 1 ┆ 2 │
╰──────────────────┴──────────────────┴────────────┴──────────┴─────────╯
```You can also set a window of time to group by rather than the commit id,
which is useful when you're looking for coupling over multiple
repositoriesLet's make another git repository
``` shell,script(name="time-windo-setup",expected_exit_code=0)
echo "time-window-setup - file_1" > "../other-repo/file_1"
echo "time-window-setup - file_2" > "../other-repo/file_2"
echo "time-window-setup - file_3" > "../other-repo/file_3"
git -C "../other-repo" add .
git -C "../other-repo" commit --message "demo: time-window-setup"
echo "time-window-setup - file_1 update" > "../other-repo/file_1"
echo "time-window-setup - file_2 update" > "../other-repo/file_2"
echo "time-window-setup - file_3 update" > "../other-repo/file_3"
git -C "../other-repo" add .
git -C "../other-repo" commit --message "demo: time-window-setup"
```Now we can look at the coupling across two repositories
``` shell,script(name="time-window",expected_exit_code=0)
git-moves-together -t 30 "$PWD" "$PWD/../other-repo"
`````` text,verify(script_name="time-window",stream=stdout)
╭───────────────────┬───────────────────┬────────────┬──────────┬─────────╮
│ File A ┆ File B ┆ Together % ┆ Together ┆ Commits │
╞═══════════════════╪═══════════════════╪════════════╪══════════╪═════════╡
│ other-repo@file_1 ┆ other-repo@file_2 ┆ 100.00% ┆ 2 ┆ 2 │
├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌┤
│ other-repo@file_1 ┆ other-repo@file_3 ┆ 100.00% ┆ 2 ┆ 2 │
├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌┤
│ other-repo@file_1 ┆ some-repo@file_1 ┆ 33.33% ┆ 2 ┆ 6 │
├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌┤
│ other-repo@file_1 ┆ some-repo@file_2 ┆ 40.00% ┆ 2 ┆ 5 │
├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌┤
│ other-repo@file_1 ┆ some-repo@file_3 ┆ 40.00% ┆ 2 ┆ 5 │
├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌┤
│ other-repo@file_2 ┆ other-repo@file_3 ┆ 100.00% ┆ 2 ┆ 2 │
├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌┤
│ other-repo@file_2 ┆ some-repo@file_1 ┆ 33.33% ┆ 2 ┆ 6 │
├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌┤
│ other-repo@file_2 ┆ some-repo@file_2 ┆ 40.00% ┆ 2 ┆ 5 │
├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌┤
│ other-repo@file_2 ┆ some-repo@file_3 ┆ 40.00% ┆ 2 ┆ 5 │
├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌┤
│ other-repo@file_3 ┆ some-repo@file_1 ┆ 33.33% ┆ 2 ┆ 6 │
├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌┤
│ other-repo@file_3 ┆ some-repo@file_2 ┆ 40.00% ┆ 2 ┆ 5 │
├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌┤
│ other-repo@file_3 ┆ some-repo@file_3 ┆ 40.00% ┆ 2 ┆ 5 │
├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌┤
│ some-repo@file_1 ┆ some-repo@file_2 ┆ 83.33% ┆ 5 ┆ 6 │
├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌┤
│ some-repo@file_1 ┆ some-repo@file_3 ┆ 83.33% ┆ 5 ┆ 6 │
├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌┤
│ some-repo@file_2 ┆ some-repo@file_3 ┆ 100.00% ┆ 5 ┆ 5 │
╰───────────────────┴───────────────────┴────────────┴──────────┴─────────╯
```Which is why you see the coupling as shown above
## Usage
``` shell,script(name="help",expected_exit_code=0)
git-moves-together -h
`````` text,verify(script_name="help",stream=stdout)
Find files that move at the same time in a git repository to identify couplingUsage: git-moves-together [OPTIONS] [GIT_REPO]...
Arguments:
[GIT_REPO]... A repository to analyse [env: GIT_REPO=] [default: .]Options:
-d, --from-days
Ignore deltas older than the given days [env: MAX_DAYS_AGO=]
-t, --time-window-minutes
Group commits by similar time window rather than by commit id [env: TIME_WINDOW_MINUTES=]
-h, --help
Print help
-V, --version
Print version
```## Installing
See the [releases
page](https://github.com/PurpleBooth/git-moves-together/releases/latest)
we build for linux and mac, alternatively use brew``` shell,skip()
brew install PurpleBooth/repo/git-moves-together
```