├── LICENSE ├── README.md ├── git-receive-mail └── git-receive-mail.gif /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2024 Daniel Jay Haskin. 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | this software and associated documentation files (the "Software"), to deal in 7 | the Software without restriction, including without limitation the rights to 8 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 9 | the Software, and to permit persons to whom the Software is furnished to do so, 10 | subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice (including the next 13 | paragraph) shall be included in all copies or substantial portions of the 14 | Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 18 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 19 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 20 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # `git-receive-mail`: The People's Git Email Patch Tool 2 | 3 | This project attempts to make it _dead simple_ for _mere mortals_ to consume git 4 | patch emails. It aims to be The People's git email patch tool. 5 | 6 | Just run `git receive-mail`, pick the patches you want, and they are 7 | automatically applied to the current branch. 8 | 9 | ![Demo of `git receive-mail`](git-receive-mail.gif) 10 | 11 | Feature requests and bug reports are welcome! 12 | 13 | ## Usage 14 | 15 | 1. Check out the branch to which you wish to apply email patches sent via [`git 16 | send-mail`](https://git-send-email.io). 17 | 2. Navigate to your git repository and branch in the terminal. 18 | 2. Run `git receive-mail`. 19 | 3. Use the arrow keys to move around and the tab key to select/deselect patches. 20 | 4. Hit Enter. 21 | 22 | The patches in the emails will be applied to the currently checked out git 23 | branch. 24 | 25 | # Goals and Non-Goals 26 | 27 | **Goals**: 28 | 29 | * Support the masses. 30 | * Usable on pretty much any OS. 31 | * Permissively licensed (MIT). 32 | * No dependencies on specific email workflows. 33 | * Simple to use in most cases, possible to use in all cases. 34 | 35 | **Non-Goals**: 36 | 37 | * The ability for maintainers of popular projects to consume vast 38 | numbers of patches. Other projects exist for that, such as [aerc](https://aerc-mail.org/) 39 | and [b4](https://github.com/mricon/b4). 40 | * The ability for patch submitters to participate on a mailing list. That is, 41 | this tool does not make it easy to reply to plain-text emails with plain 42 | text, something [many email providers don't 43 | provide](https://www.kernel.org/doc/html/v4.10/process/email-clients.html). 44 | However, there is hope! Users can use 45 | [`himalaya`](https://pimalaya.org/himalaya/cli/latest/usage/basic/message/send.html#reply-to-a-message-interactively) 46 | as a for-purpose tool to send plain text emails. This allows the users to 47 | use whatever they normally use to check email for everything else. 48 | 49 | ## Supported OS's 50 | 51 | * Windows (via Git Bash) 52 | * Mac 53 | * Linux 54 | * All other platforms that support Golang, Rust, and POSIX shell (since the 55 | project depends on `himalaya` and `fzf`, and this version is written in POSIX 56 | shell). 57 | 58 | ## Set-Up 59 | 60 | 1. Install [himalaya](https://github.com/soywod/himalaya.git). It can be 61 | downloaded from its releases page. Often, this can simply be installed with 62 | your favorite package manager, either the system package manager or e.g. 63 | homebrew. 64 | 2. Set up `himalaya` with your IMAP credentials by running `himalaya`. A wizard 65 | will walk the user through setting this up. 66 | 2. Install [fzf](https://github.com/junegunn/fzf). It can be downloaded from its 67 | releases page. Often, this can simply be installed with your favorite package 68 | manager, either the system package manager or e.g. homebrew. 69 | 4. Download the `git-receive-mail` script included herein and put it on on the 70 | PATH. 71 | 72 | ## Advanced Usage 73 | 74 | The script passes whatever arguments sent to it into Himalaya, so reading the 75 | [documentation](https://pimalaya.org/himalaya/cli/latest/configuration/) for 76 | that tool will enable the user to construct more advanced workflows, grab 77 | patches from folders other than their INBOX, etc. For example, `git receive-mail 78 | -a ` lets the user grab the email from a specific email account. 79 | 80 | ## Contributions 81 | 82 | Contributions welcome. I don't expect this to remain a POSIX script; I'm open to 83 | PRs or patches that rewrites this simple script. Future directions might include 84 | getting rid of dependencies or rewriting entirely in golang or Python. 85 | -------------------------------------------------------------------------------- /git-receive-mail: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | email_ids=$(himalaya "${@}" | \ 4 | tail -n +2 | \ 5 | fzf --ansi \ 6 | --nth 3..5 \ 7 | --preview="himalaya message read -p ${@} {1}" \ 8 | --header-lines=1 \ 9 | --multi | \ 10 | awk -F' *| *' '/|/{print $1}') 11 | 12 | (for email_id in $email_ids; do 13 | printf '\nFrom nobody Mon Sep 17 00:00:00 2001\n' 14 | himalaya --output plain message read -p --raw "${@}" $email_id 15 | done) | git am - -------------------------------------------------------------------------------- /git-receive-mail.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/djha-skin/git-receive-mail/094f1e72add253533c610bf88d20a2c2d1b1c571/git-receive-mail.gif --------------------------------------------------------------------------------