├── .github └── workflows │ └── ci.yaml ├── COPYING ├── Dockerfile ├── README.rst ├── meson.build ├── pram ├── pram.1 └── test ├── 00basic.sh ├── 01signoff-missing.sh ├── 01signoff-partial.sh ├── 01signoff-present.sh ├── 02bug-number.sh ├── 02bug-url.sh ├── 02closes-number.sh ├── 02closes-url.sh ├── 03bug-multiple.sh ├── 03closes-multiple.sh ├── 03combined-bug-closes.sh ├── 03combined-signoff-bug.sh ├── 04interactive-no.sh ├── 04interactive-yes.sh ├── 05editor-empty.sh ├── 05editor-fail.sh ├── 06gpgsign.sh ├── 10threeway-disabled.sh ├── 10threeway.sh ├── 11combined-partof-signoff-bug.sh ├── 11partof.sh └── common-setup.sh /.github/workflows/ci.yaml: -------------------------------------------------------------------------------- 1 | name: CI 2 | on: [push, pull_request] 3 | jobs: 4 | test: 5 | runs-on: ubuntu-latest 6 | steps: 7 | - name: Checkout 8 | uses: actions/checkout@v2 9 | - name: Install deps 10 | run: sudo apt install -y meson 11 | - name: Build new git, sigh 12 | run: | 13 | wget https://mirrors.edge.kernel.org/pub/software/scm/git/git-2.45.0.tar.xz 14 | tar -xJf git-2.45.0.tar.xz 15 | cd git-2.45.0 16 | make -j$(nproc) NO_CURL=1 NO_GETTEXT=1 17 | sudo make install NO_CURL=1 NO_GETTEXT=1 prefix=/usr/local 18 | - name: Configure 19 | run: meson setup build 20 | - name: Test 21 | run: meson test -C build --print-errorlogs 22 | -------------------------------------------------------------------------------- /COPYING: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 2, June 1991 3 | 4 | Copyright (C) 1989, 1991 Free Software Foundation, Inc., 5 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 6 | Everyone is permitted to copy and distribute verbatim copies 7 | of this license document, but changing it is not allowed. 8 | 9 | Preamble 10 | 11 | The licenses for most software are designed to take away your 12 | freedom to share and change it. By contrast, the GNU General Public 13 | License is intended to guarantee your freedom to share and change free 14 | software--to make sure the software is free for all its users. This 15 | General Public License applies to most of the Free Software 16 | Foundation's software and to any other program whose authors commit to 17 | using it. (Some other Free Software Foundation software is covered by 18 | the GNU Lesser General Public License instead.) You can apply it to 19 | your programs, too. 20 | 21 | When we speak of free software, we are referring to freedom, not 22 | price. Our General Public Licenses are designed to make sure that you 23 | have the freedom to distribute copies of free software (and charge for 24 | this service if you wish), that you receive source code or can get it 25 | if you want it, that you can change the software or use pieces of it 26 | in new free programs; and that you know you can do these things. 27 | 28 | To protect your rights, we need to make restrictions that forbid 29 | anyone to deny you these rights or to ask you to surrender the rights. 30 | These restrictions translate to certain responsibilities for you if you 31 | distribute copies of the software, or if you modify it. 32 | 33 | For example, if you distribute copies of such a program, whether 34 | gratis or for a fee, you must give the recipients all the rights that 35 | you have. You must make sure that they, too, receive or can get the 36 | source code. And you must show them these terms so they know their 37 | rights. 38 | 39 | We protect your rights with two steps: (1) copyright the software, and 40 | (2) offer you this license which gives you legal permission to copy, 41 | distribute and/or modify the software. 42 | 43 | Also, for each author's protection and ours, we want to make certain 44 | that everyone understands that there is no warranty for this free 45 | software. If the software is modified by someone else and passed on, we 46 | want its recipients to know that what they have is not the original, so 47 | that any problems introduced by others will not reflect on the original 48 | authors' reputations. 49 | 50 | Finally, any free program is threatened constantly by software 51 | patents. We wish to avoid the danger that redistributors of a free 52 | program will individually obtain patent licenses, in effect making the 53 | program proprietary. To prevent this, we have made it clear that any 54 | patent must be licensed for everyone's free use or not licensed at all. 55 | 56 | The precise terms and conditions for copying, distribution and 57 | modification follow. 58 | 59 | GNU GENERAL PUBLIC LICENSE 60 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 61 | 62 | 0. This License applies to any program or other work which contains 63 | a notice placed by the copyright holder saying it may be distributed 64 | under the terms of this General Public License. The "Program", below, 65 | refers to any such program or work, and a "work based on the Program" 66 | means either the Program or any derivative work under copyright law: 67 | that is to say, a work containing the Program or a portion of it, 68 | either verbatim or with modifications and/or translated into another 69 | language. (Hereinafter, translation is included without limitation in 70 | the term "modification".) Each licensee is addressed as "you". 71 | 72 | Activities other than copying, distribution and modification are not 73 | covered by this License; they are outside its scope. The act of 74 | running the Program is not restricted, and the output from the Program 75 | is covered only if its contents constitute a work based on the 76 | Program (independent of having been made by running the Program). 77 | Whether that is true depends on what the Program does. 78 | 79 | 1. You may copy and distribute verbatim copies of the Program's 80 | source code as you receive it, in any medium, provided that you 81 | conspicuously and appropriately publish on each copy an appropriate 82 | copyright notice and disclaimer of warranty; keep intact all the 83 | notices that refer to this License and to the absence of any warranty; 84 | and give any other recipients of the Program a copy of this License 85 | along with the Program. 86 | 87 | You may charge a fee for the physical act of transferring a copy, and 88 | you may at your option offer warranty protection in exchange for a fee. 89 | 90 | 2. You may modify your copy or copies of the Program or any portion 91 | of it, thus forming a work based on the Program, and copy and 92 | distribute such modifications or work under the terms of Section 1 93 | above, provided that you also meet all of these conditions: 94 | 95 | a) You must cause the modified files to carry prominent notices 96 | stating that you changed the files and the date of any change. 97 | 98 | b) You must cause any work that you distribute or publish, that in 99 | whole or in part contains or is derived from the Program or any 100 | part thereof, to be licensed as a whole at no charge to all third 101 | parties under the terms of this License. 102 | 103 | c) If the modified program normally reads commands interactively 104 | when run, you must cause it, when started running for such 105 | interactive use in the most ordinary way, to print or display an 106 | announcement including an appropriate copyright notice and a 107 | notice that there is no warranty (or else, saying that you provide 108 | a warranty) and that users may redistribute the program under 109 | these conditions, and telling the user how to view a copy of this 110 | License. (Exception: if the Program itself is interactive but 111 | does not normally print such an announcement, your work based on 112 | the Program is not required to print an announcement.) 113 | 114 | These requirements apply to the modified work as a whole. If 115 | identifiable sections of that work are not derived from the Program, 116 | and can be reasonably considered independent and separate works in 117 | themselves, then this License, and its terms, do not apply to those 118 | sections when you distribute them as separate works. But when you 119 | distribute the same sections as part of a whole which is a work based 120 | on the Program, the distribution of the whole must be on the terms of 121 | this License, whose permissions for other licensees extend to the 122 | entire whole, and thus to each and every part regardless of who wrote it. 123 | 124 | Thus, it is not the intent of this section to claim rights or contest 125 | your rights to work written entirely by you; rather, the intent is to 126 | exercise the right to control the distribution of derivative or 127 | collective works based on the Program. 128 | 129 | In addition, mere aggregation of another work not based on the Program 130 | with the Program (or with a work based on the Program) on a volume of 131 | a storage or distribution medium does not bring the other work under 132 | the scope of this License. 133 | 134 | 3. You may copy and distribute the Program (or a work based on it, 135 | under Section 2) in object code or executable form under the terms of 136 | Sections 1 and 2 above provided that you also do one of the following: 137 | 138 | a) Accompany it with the complete corresponding machine-readable 139 | source code, which must be distributed under the terms of Sections 140 | 1 and 2 above on a medium customarily used for software interchange; or, 141 | 142 | b) Accompany it with a written offer, valid for at least three 143 | years, to give any third party, for a charge no more than your 144 | cost of physically performing source distribution, a complete 145 | machine-readable copy of the corresponding source code, to be 146 | distributed under the terms of Sections 1 and 2 above on a medium 147 | customarily used for software interchange; or, 148 | 149 | c) Accompany it with the information you received as to the offer 150 | to distribute corresponding source code. (This alternative is 151 | allowed only for noncommercial distribution and only if you 152 | received the program in object code or executable form with such 153 | an offer, in accord with Subsection b above.) 154 | 155 | The source code for a work means the preferred form of the work for 156 | making modifications to it. For an executable work, complete source 157 | code means all the source code for all modules it contains, plus any 158 | associated interface definition files, plus the scripts used to 159 | control compilation and installation of the executable. However, as a 160 | special exception, the source code distributed need not include 161 | anything that is normally distributed (in either source or binary 162 | form) with the major components (compiler, kernel, and so on) of the 163 | operating system on which the executable runs, unless that component 164 | itself accompanies the executable. 165 | 166 | If distribution of executable or object code is made by offering 167 | access to copy from a designated place, then offering equivalent 168 | access to copy the source code from the same place counts as 169 | distribution of the source code, even though third parties are not 170 | compelled to copy the source along with the object code. 171 | 172 | 4. You may not copy, modify, sublicense, or distribute the Program 173 | except as expressly provided under this License. Any attempt 174 | otherwise to copy, modify, sublicense or distribute the Program is 175 | void, and will automatically terminate your rights under this License. 176 | However, parties who have received copies, or rights, from you under 177 | this License will not have their licenses terminated so long as such 178 | parties remain in full compliance. 179 | 180 | 5. You are not required to accept this License, since you have not 181 | signed it. However, nothing else grants you permission to modify or 182 | distribute the Program or its derivative works. These actions are 183 | prohibited by law if you do not accept this License. Therefore, by 184 | modifying or distributing the Program (or any work based on the 185 | Program), you indicate your acceptance of this License to do so, and 186 | all its terms and conditions for copying, distributing or modifying 187 | the Program or works based on it. 188 | 189 | 6. Each time you redistribute the Program (or any work based on the 190 | Program), the recipient automatically receives a license from the 191 | original licensor to copy, distribute or modify the Program subject to 192 | these terms and conditions. You may not impose any further 193 | restrictions on the recipients' exercise of the rights granted herein. 194 | You are not responsible for enforcing compliance by third parties to 195 | this License. 196 | 197 | 7. If, as a consequence of a court judgment or allegation of patent 198 | infringement or for any other reason (not limited to patent issues), 199 | conditions are imposed on you (whether by court order, agreement or 200 | otherwise) that contradict the conditions of this License, they do not 201 | excuse you from the conditions of this License. If you cannot 202 | distribute so as to satisfy simultaneously your obligations under this 203 | License and any other pertinent obligations, then as a consequence you 204 | may not distribute the Program at all. For example, if a patent 205 | license would not permit royalty-free redistribution of the Program by 206 | all those who receive copies directly or indirectly through you, then 207 | the only way you could satisfy both it and this License would be to 208 | refrain entirely from distribution of the Program. 209 | 210 | If any portion of this section is held invalid or unenforceable under 211 | any particular circumstance, the balance of the section is intended to 212 | apply and the section as a whole is intended to apply in other 213 | circumstances. 214 | 215 | It is not the purpose of this section to induce you to infringe any 216 | patents or other property right claims or to contest validity of any 217 | such claims; this section has the sole purpose of protecting the 218 | integrity of the free software distribution system, which is 219 | implemented by public license practices. Many people have made 220 | generous contributions to the wide range of software distributed 221 | through that system in reliance on consistent application of that 222 | system; it is up to the author/donor to decide if he or she is willing 223 | to distribute software through any other system and a licensee cannot 224 | impose that choice. 225 | 226 | This section is intended to make thoroughly clear what is believed to 227 | be a consequence of the rest of this License. 228 | 229 | 8. If the distribution and/or use of the Program is restricted in 230 | certain countries either by patents or by copyrighted interfaces, the 231 | original copyright holder who places the Program under this License 232 | may add an explicit geographical distribution limitation excluding 233 | those countries, so that distribution is permitted only in or among 234 | countries not thus excluded. In such case, this License incorporates 235 | the limitation as if written in the body of this License. 236 | 237 | 9. The Free Software Foundation may publish revised and/or new versions 238 | of the General Public License from time to time. Such new versions will 239 | be similar in spirit to the present version, but may differ in detail to 240 | address new problems or concerns. 241 | 242 | Each version is given a distinguishing version number. If the Program 243 | specifies a version number of this License which applies to it and "any 244 | later version", you have the option of following the terms and conditions 245 | either of that version or of any later version published by the Free 246 | Software Foundation. If the Program does not specify a version number of 247 | this License, you may choose any version ever published by the Free Software 248 | Foundation. 249 | 250 | 10. If you wish to incorporate parts of the Program into other free 251 | programs whose distribution conditions are different, write to the author 252 | to ask for permission. For software which is copyrighted by the Free 253 | Software Foundation, write to the Free Software Foundation; we sometimes 254 | make exceptions for this. Our decision will be guided by the two goals 255 | of preserving the free status of all derivatives of our free software and 256 | of promoting the sharing and reuse of software generally. 257 | 258 | NO WARRANTY 259 | 260 | 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY 261 | FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN 262 | OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES 263 | PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED 264 | OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 265 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS 266 | TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE 267 | PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, 268 | REPAIR OR CORRECTION. 269 | 270 | 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 271 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR 272 | REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, 273 | INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING 274 | OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED 275 | TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY 276 | YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER 277 | PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE 278 | POSSIBILITY OF SUCH DAMAGES. 279 | 280 | END OF TERMS AND CONDITIONS 281 | 282 | How to Apply These Terms to Your New Programs 283 | 284 | If you develop a new program, and you want it to be of the greatest 285 | possible use to the public, the best way to achieve this is to make it 286 | free software which everyone can redistribute and change under these terms. 287 | 288 | To do so, attach the following notices to the program. It is safest 289 | to attach them to the start of each source file to most effectively 290 | convey the exclusion of warranty; and each file should have at least 291 | the "copyright" line and a pointer to where the full notice is found. 292 | 293 | 294 | Copyright (C) 295 | 296 | This program is free software; you can redistribute it and/or modify 297 | it under the terms of the GNU General Public License as published by 298 | the Free Software Foundation; either version 2 of the License, or 299 | (at your option) any later version. 300 | 301 | This program is distributed in the hope that it will be useful, 302 | but WITHOUT ANY WARRANTY; without even the implied warranty of 303 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 304 | GNU General Public License for more details. 305 | 306 | You should have received a copy of the GNU General Public License along 307 | with this program; if not, write to the Free Software Foundation, Inc., 308 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 309 | 310 | Also add information on how to contact you by electronic and paper mail. 311 | 312 | If the program is interactive, make it output a short notice like this 313 | when it starts in an interactive mode: 314 | 315 | Gnomovision version 69, Copyright (C) year name of author 316 | Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 317 | This is free software, and you are welcome to redistribute it 318 | under certain conditions; type `show c' for details. 319 | 320 | The hypothetical commands `show w' and `show c' should show the appropriate 321 | parts of the General Public License. Of course, the commands you use may 322 | be called something other than `show w' and `show c'; they could even be 323 | mouse-clicks or menu items--whatever suits your program. 324 | 325 | You should also get your employer (if you work as a programmer) or your 326 | school, if any, to sign a "copyright disclaimer" for the program, if 327 | necessary. Here is a sample; alter the names: 328 | 329 | Yoyodyne, Inc., hereby disclaims all copyright interest in the program 330 | `Gnomovision' (which makes passes at compilers) written by James Hacker. 331 | 332 | , 1 April 1989 333 | Ty Coon, President of Vice 334 | 335 | This General Public License does not permit incorporating your program into 336 | proprietary programs. If your program is a subroutine library, you may 337 | consider it more useful to permit linking proprietary applications with the 338 | library. If this is what you want to do, use the GNU Lesser General 339 | Public License instead of this License. 340 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM alpine 2 | WORKDIR /pram/build 3 | COPY . /pram 4 | RUN ["apk", "add", "bash", "diffutils", "git", "meson", "ninja"] 5 | RUN ["meson", ".."] 6 | RUN ["ninja"] 7 | CMD ["ninja", "test"] 8 | -------------------------------------------------------------------------------- /README.rst: -------------------------------------------------------------------------------- 1 | ==== 2 | PRam 3 | ==== 4 | 5 | This is an enhanced rewrite of Patrice Clement's pram utility, in bash 6 | [#CLEMENT-PRAM]_. It is a tool to ease merging of pull requests 7 | and git format patches to ebuild repositories. It incorporates 8 | the requirements of Gentoo policies and reduces the necessity 9 | of manually updating commit messages [#GLEP66]_ [#GLEP76]_. 10 | 11 | 12 | Merging pull requests 13 | --------------------- 14 | To merge GitHub PR #12345, enter your local gentoo.git checkout 15 | and type:: 16 | 17 | pram 12345 18 | 19 | This will fetch it from gentoo/gentoo repository, verify the presence 20 | of author's sign-off, append appropriate ``Closes`` trailer and merge 21 | it via ``git am``. 22 | 23 | You can request referencing or closing additional bugs using ``--bug`` 24 | and ``--closes`` options appropriately (they can be specified multiple 25 | times). Note that PRam appends the relevant trailers only to the last 26 | commit in batch; you may want to move them around via editor. 27 | 28 | 29 | Merging Bugzilla patches 30 | ------------------------ 31 | PRam can also merge patches from Gentoo Bugzilla. To do that, use 32 | the full URL to the patch file, e.g.:: 33 | 34 | pram https://123456.bugs.gentoo.org/attachment.cgi?id=123456 35 | 36 | PRam will automatically request closing that bug as well. If this is 37 | undesirable, remove the added ``Closes`` trailer via editor. 38 | 39 | 40 | Working with other repositories 41 | ------------------------------- 42 | You can easily use PRam with other repositories. You can either use 43 | the ``--repository`` option to override the remote GitHub repository 44 | or specify a full PR URL:: 45 | 46 | pram -r foo/gentoo 123 47 | pram https://github.com/foo/gentoo/pull/123 48 | 49 | If your repository does not use DCO/GCO, you can use ``--no-signoff`` 50 | option to disable requiring sign-off. 51 | 52 | 53 | References 54 | ---------- 55 | .. [#CLEMENT-PRAM] Patrice Clement: Gentoo-App-Pram 56 | (https://github.com/monsieurp/Gentoo-App-Pram/) 57 | 58 | .. [#GLEP66] GLEP 66: Gentoo Git Workflow 59 | (https://www.gentoo.org/glep/glep-0066.html) 60 | 61 | .. [#GLEP76] GLEP 76: Copyright Policy 62 | (https://www.gentoo.org/glep/glep-0076.html) 63 | 64 | 65 | Copyright 66 | --------- 67 | This program is free software; you can redistribute it and/or modify 68 | it under the terms of the GNU General Public License as published by 69 | the Free Software Foundation; either version 2 of the License, or 70 | (at your option) any later version. 71 | 72 | This program is distributed in the hope that it will be useful, 73 | but WITHOUT ANY WARRANTY; without even the implied warranty of 74 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 75 | GNU General Public License for more details. 76 | 77 | You should have received a copy of the GNU General Public License along 78 | with this program; if not, write to the Free Software Foundation, Inc., 79 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 80 | -------------------------------------------------------------------------------- /meson.build: -------------------------------------------------------------------------------- 1 | project('pram', 2 | version: '14', 3 | license: 'GPL-2.0-or-later', 4 | meson_version: '>=0.49.0') 5 | 6 | install_data('pram', 7 | install_dir: get_option('bindir'), 8 | install_mode: 'rwxr-xr-x') 9 | install_man('pram.1') 10 | 11 | sh = find_program('sh') 12 | tests = [ 13 | '00basic', 14 | '01signoff-missing', 15 | '01signoff-partial', 16 | '01signoff-present', 17 | '02bug-number', 18 | '02bug-url', 19 | '02closes-number', 20 | '02closes-url', 21 | '03bug-multiple', 22 | '03closes-multiple', 23 | '03combined-bug-closes', 24 | '03combined-signoff-bug', 25 | '04interactive-no', 26 | '04interactive-yes', 27 | '05editor-empty', 28 | '05editor-fail', 29 | '06gpgsign', 30 | '10threeway', 31 | '10threeway-disabled', 32 | '11combined-partof-signoff-bug', 33 | '11partof', 34 | ] 35 | 36 | foreach t : tests 37 | test(t, sh, 38 | args: [t + '.sh'], 39 | workdir: meson.current_source_dir() / 'test') 40 | endforeach 41 | -------------------------------------------------------------------------------- /pram: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # (c) 2019-2025 Michał Górny 3 | # SPDX-License-Identifier: GPL-2.0-or-later 4 | 5 | VERSION=14 6 | 7 | die() { 8 | echo "${@}" >&2 9 | exit 1 10 | } 11 | 12 | print_usage() { 13 | echo "Usage: ${0} [] " 14 | } 15 | 16 | print_help() { 17 | print_usage 18 | echo 19 | echo "Merge specified GitHub PR into the repository in current directory." 20 | echo 21 | echo "Options:" 22 | echo " --am-options OPTIONS" 23 | echo " Pass additional OPTIONS to git am" 24 | echo " -b BUG, --bug BUG" 25 | echo " -c BUG, --closes BUG" 26 | echo " Reference or close the specific bug, takes either" 27 | echo " a bug number or URL, can be specified multiple times" 28 | echo " -e EDITOR, --editor EDITOR" 29 | echo " Override the editor used (default: \${EDITOR})" 30 | echo " --no-api Don't use the GitHub REST API even if a personal" 31 | echo " access token is present at ~/.github-token" 32 | echo " --no-gitconfig Do not query options via git config" 33 | echo " -G, --no-gpgsign" 34 | echo " Do not automatically GPG-sign commits" 35 | echo " -I, --non-interactive" 36 | echo " Do not interactively ask to merge, just do it" 37 | echo " -r REPO, --repository REPO" 38 | echo " GitHub repo to use (default: gentoo/gentoo)" 39 | echo " -s, --signoff Add Signed-off-by to commits (the default)" 40 | echo " -S, --no-signoff Disable adding Signed-off-by to commits" 41 | echo " -p, --part-of Add Part-of to commits, linking to the PR (the default)" 42 | echo " -P, --no-part-of Disable adding Part-of to commits" 43 | echo " --link-to PULL_REQUEST" 44 | echo " Override the pull request the merge is linked to. This" 45 | echo " will override the Part-of trailer, as well as the final" 46 | echo " Closes trailer." 47 | echo 48 | echo "Parameters:" 49 | echo " GitHub PR number" 50 | echo " Full URL to the pull request" 51 | echo " URL to a patch file" 52 | echo 53 | echo "Some options can be specified via 'git config' as well:" 54 | echo " string options: pram.editor, pram.repo" 55 | echo " boolean options: pram.gpgsign, pram.interactive, pram.signoff, pram.partof" 56 | } 57 | 58 | # add_trailer 59 | add_trailer() { 60 | local file=${1} 61 | local line=${2} 62 | 63 | sed -i -e "1,/^---$/s@^---\$@${line}\n\0@" "${file}" || 64 | die "Appending trailer via sed failed" 65 | } 66 | 67 | main() { 68 | # make sure files are sorted ascending 69 | local -x LC_COLLATE=C 70 | 71 | local am_options=() 72 | local api= 73 | local bug=() 74 | local closes=() 75 | local editor= 76 | local pr= 77 | local repo= 78 | local signoff=def 79 | local interactive=def 80 | local gitconfig=1 81 | local gpgsign=def 82 | local partof=def 83 | local link_to= 84 | 85 | if [[ -r ~/.github-token ]]; then 86 | api=1 87 | fi 88 | 89 | while [[ ${#} -gt 0 ]]; do 90 | case ${1} in 91 | -h|--help) 92 | print_help 93 | exit 0 94 | ;; 95 | -V|--version) 96 | echo "pram ${VERSION}" 97 | exit 0 98 | ;; 99 | 100 | --am-options) 101 | [[ ${#} -gt 1 ]] || die "${0}: missing argument to ${1}" 102 | am_options+=( "${2}" ) 103 | shift 104 | ;; 105 | --am-options=*) 106 | am_options+=( "${1#*=}" ) 107 | ;; 108 | -b|--bug) 109 | [[ ${#} -gt 1 ]] || die "${0}: missing argument to ${1}" 110 | bug+=( "${2}" ) 111 | shift 112 | ;; 113 | -b*) 114 | bug+=( "${1#-b}" ) 115 | ;; 116 | --bug=*) 117 | bug+=( "${1#*=}" ) 118 | ;; 119 | -c|--closes) 120 | [[ ${#} -gt 1 ]] || die "${0}: missing argument to ${1}" 121 | closes+=( "${2}" ) 122 | shift 123 | ;; 124 | -c*) 125 | closes+=( "${1#-c}" ) 126 | ;; 127 | --closes=*) 128 | closes+=( "${1#*=}" ) 129 | ;; 130 | -e|--editor) 131 | [[ ${#} -gt 1 ]] || die "${0}: missing argument to ${1}" 132 | editor=${2} 133 | shift 134 | ;; 135 | -e*) 136 | editor=${1#-e} 137 | ;; 138 | --editor=*) 139 | editor=${1#*=} 140 | ;; 141 | --no-api) 142 | api= 143 | ;; 144 | --no-gitconfig) 145 | gitconfig= 146 | ;; 147 | -G|--no-gpgsign) 148 | gpgsign= 149 | ;; 150 | -I|--non-interactive) 151 | interactive= 152 | ;; 153 | -r|--repository) 154 | [[ ${#} -gt 1 ]] || die "${0}: missing argument to ${1}" 155 | repo=${2} 156 | shift 157 | ;; 158 | -r*) 159 | repo=${1#-r} 160 | ;; 161 | --repository=*) 162 | repo=${1#*=} 163 | ;; 164 | -s|--signoff) 165 | signoff=1 166 | ;; 167 | -S|--no-signoff) 168 | signoff= 169 | ;; 170 | -p|--part-of) 171 | partof=1 172 | ;; 173 | -P|--no-part-of) 174 | partof= 175 | ;; 176 | --link-to) 177 | [[ -z ${link_to} ]] || die "${0}: cannot specify multiple ${1}" 178 | [[ ${#} -gt 1 ]] || die "${0}: missing argument to ${1}" 179 | link_to=${2} 180 | shift 181 | ;; 182 | --link-to=*) 183 | [[ -z ${link_to} ]] || die "${0}: cannot specify multiple ${1%%=*}" 184 | link_to=${1#*=} 185 | ;; 186 | -*) 187 | print_usage >&2 188 | exit 1 189 | ;; 190 | *) 191 | if [[ -n ${pr} ]]; then 192 | echo "${0}: only a single PR/patch can be specified" >&2 193 | print_usage >&2 194 | exit 1 195 | fi 196 | pr=${1} 197 | ;; 198 | esac 199 | 200 | shift 201 | done 202 | 203 | if [[ -z ${pr} ]]; then 204 | print_usage >&2 205 | exit 1 206 | fi 207 | 208 | if [[ $(git rev-parse --is-inside-work-tree) != true ]]; then 209 | echo "pram needs to be run inside the git checkout!" >&2 210 | exit 1 211 | fi 212 | 213 | if [[ ${gitconfig} ]]; then 214 | local opt 215 | 216 | # string options 217 | [[ -z ${repo} ]] && repo=$(git config --get pram.repo) 218 | [[ -z ${editor} ]] && editor=$(git config --get pram.editor) 219 | 220 | # boolean options 221 | if [[ ${signoff} == def ]]; then 222 | opt=$(git config --type bool --get pram.signoff) 223 | [[ ${opt} == true ]] && signoff=1 224 | [[ ${opt} == false ]] && signoff= 225 | fi 226 | if [[ ${interactive} == def ]]; then 227 | opt=$(git config --type bool --get pram.interactive) 228 | [[ ${opt} == true ]] && interactive=1 229 | [[ ${opt} == false ]] && interactive= 230 | fi 231 | if [[ ${gpgsign} == def ]]; then 232 | opt=$(git config --type bool --get pram.gpgsign) 233 | [[ ${opt} == true ]] && gpgsign=1 234 | [[ ${opt} == false ]] && gpgsign= 235 | fi 236 | if [[ ${partof} == def ]]; then 237 | opt=$(git config --type bool --get pram.partof) 238 | [[ ${opt} == true ]] && partof=1 239 | [[ ${opt} == false ]] && partof= 240 | fi 241 | fi 242 | 243 | # set defaults 244 | : "${repo:=gentoo/gentoo}" 245 | : "${editor:=${EDITOR:-vim}}" 246 | 247 | tempdir=$(mktemp -d) || die "Unable to create a temporary directory" 248 | trap 'rm -r -f "${tempdir}"' EXIT 249 | 250 | local to_close 251 | case ${pr} in 252 | *://github.com/*/*/pull/*/commits/*) 253 | # Simplify for easier use via the api 254 | pr=${pr/pull\/*\/commits/commit} 255 | pr=${pr%.patch}.patch 256 | to_close= 257 | ;; 258 | *://github.com/*/*/pull/*) 259 | # GitHub URL 260 | to_close=${pr%.patch} 261 | pr=${to_close}.patch 262 | ;; 263 | *://github.com/*/*/commit/*|*://github.com/*/*/compare/*) 264 | # GitHub branch/commit diff 265 | pr=${pr%.patch}.patch 266 | to_close= 267 | ;; 268 | *://*.bugs.gentoo.org/attachment.cgi?*) 269 | # Gentoo Bugzilla attachment 270 | # (get bug no from domain name) 271 | to_close=${pr%%.bugs*} 272 | to_close="https://bugs.gentoo.org/${to_close#*://}" 273 | ;; 274 | *://*) 275 | # arbitrary URL 276 | to_close= 277 | ;; 278 | [0-9]*) 279 | # a number? 280 | to_close="https://github.com/${repo}/pull/${pr}" 281 | pr=${to_close}.patch 282 | ;; 283 | *) 284 | # a local file maybe? 285 | to_close= 286 | [[ -f ${pr} ]] || 287 | die "Parameter neither an URL, number or file: ${pr}" 288 | cp "${pr}" "${tempdir}"/all.patch || die "Copying patch failed" 289 | pr= 290 | ;; 291 | esac 292 | 293 | if [[ -z ${to_close} && -z ${link_to} ]]; then 294 | # only add partof for local files and arbitrary URLs if explicitly asked for 295 | if [[ ${partof} == def ]]; then 296 | partof= 297 | elif [[ ${partof} ]]; then 298 | die "could not determine a PR from supplied patch, please specify with --link-to" 299 | fi 300 | fi 301 | 302 | if [[ -n ${pr} ]]; then 303 | if [[ -n ${api} && ( 304 | ${pr} == *://github.com/*/commit/* || 305 | ${pr} == *://github.com/*/compare/* || 306 | ${pr} == *://github.com/*/pull/* ) 307 | ]]; then 308 | # Modify possible patch links to be applicable to the GitHub REST API 309 | # https://docs.github.com/en/rest?apiVersion=2022-11-28 310 | pr=${pr/github.com/api.github.com\/repos} 311 | pr=${pr/\/commit\//\/commits\/} 312 | pr=${pr/\/pull\//\/pulls\/} 313 | pr=${pr%%.patch} 314 | wget --header="Authorization: Bearer $(< ~/.github-token)" \ 315 | --header="Accept: application/vnd.github.patch" \ 316 | --header="X-GitHub-Api-Version: 2022-11-28" \ 317 | -O "${tempdir}/all.patch" "${pr}" || die "Fetching patch failed" 318 | else 319 | wget -O "${tempdir}/all.patch" "${pr}" || die "Fetching patch failed" 320 | fi 321 | fi 322 | git mailsplit --keep-cr -o"${tempdir}" "${tempdir}/all.patch" >/dev/null || 323 | die "Splitting patches failed" 324 | 325 | if [[ ${partof} && -n ${link_to} ]]; then 326 | case ${link_to} in 327 | *://*) 328 | # already fine 329 | to_close=${link_to} 330 | ;; 331 | [0-9]*) 332 | to_close="https://github.com/${repo}/pull/${link_to}" 333 | ;; 334 | *) 335 | die "Unknown format for linked pull request: ${link_to}" 336 | ;; 337 | esac 338 | 339 | fi 340 | 341 | local patches=( "${tempdir}"/[0-9]* ) 342 | if [[ ${signoff} || ${partof} ]]; then 343 | local f 344 | for f in "${patches[@]}"; do 345 | if [[ ${signoff} ]]; then 346 | if ! grep -q '^Signed-off-by:' "${f}"; then 347 | die "Commit no. ${f##*/} was not signed off by the author!" 348 | fi 349 | fi 350 | 351 | if [[ ${partof} ]]; then 352 | add_trailer "${f}" "Part-of: ${to_close}" 353 | fi 354 | done 355 | fi 356 | 357 | # append bug references 358 | local b 359 | for b in "${bug[@]}"; do 360 | [[ ${b} != *://* ]] && b=https://bugs.gentoo.org/${b} 361 | add_trailer "${patches[-1]}" "Bug: ${b}" 362 | done 363 | for b in "${closes[@]}"; do 364 | [[ ${b} != *://* ]] && b=https://bugs.gentoo.org/${b} 365 | add_trailer "${patches[-1]}" "Closes: ${b}" 366 | done 367 | # append Closes: to the final commit if missing 368 | if [[ -n ${to_close} ]]; then 369 | if ! grep -q "^Closes: ${to_close}" "${patches[-1]}"; then 370 | add_trailer "${patches[-1]}" "Closes: ${to_close}" 371 | fi 372 | fi 373 | 374 | # concatenate the patches back 375 | cat "${patches[@]}" > "${tempdir}/all.patch" || 376 | die "Concatenating patches failed" 377 | rm "${patches[@]}" || die "Split patch cleanup failed" 378 | 379 | ${editor} "${tempdir}/all.patch" || die "Starting editor failed" 380 | 381 | if [[ ! -s ${tempdir}/all.patch ]]; then 382 | echo "Patch is empty now, nothing to do." >&2 383 | return 0 384 | fi 385 | 386 | if [[ ${interactive} ]]; then 387 | while :; do 388 | local answer 389 | read -p "Do you want to merge this? (Y/n/q) " answer 390 | case ${answer,,} in 391 | y|"") 392 | break 393 | ;; 394 | q|n) 395 | return 0 396 | ;; 397 | *) 398 | echo "Unknown answer." 399 | ;; 400 | esac 401 | done 402 | fi 403 | git am --keep-cr -3 ${signoff:+-s} ${gpgsign:+-S} "${am_options[@]}" \ 404 | "${tempdir}/all.patch" || die "git am failed" 405 | } 406 | 407 | main "${@}" 408 | -------------------------------------------------------------------------------- /pram.1: -------------------------------------------------------------------------------- 1 | .TH PRAM 9 "2025-05-14" "pram 14" 2 | 3 | .SH NAME 4 | PRam \- Tool to ease merging Pull Requests and git patches 5 | 6 | .SH SYNOPSIS 7 | .B pram 8 | [\fI\fP] \fI\fP 9 | 10 | .SH DESCRIPTION 11 | Merge specified GitHub PR into the repository in current directory. 12 | 13 | .SH OPTIONS 14 | .TP 15 | \fB\-\-am\-options\fR \fIOPTIONS\fP 16 | Pass additional options to git am 17 | .TP 18 | \fB\-b\fR \fIBUG\fP, \fB\-\-bug\fR \fIBUG\fP, \fB\-c\fR \fIBUG\fP, \fB\-\-closes\fR \fIBUG\fP 19 | Reference or close the specific bug, takes either a bug number or URL, can be 20 | specified multiple times. 21 | .TP 22 | \fB\-e\fR \fIEDITOR\fP, \fB\-\-editor\fP \fIEDITOR\fP 23 | Override the editor used (default: ${EDITOR}) 24 | .TP 25 | \fB\-\-no\-gitconfig\fR 26 | Do not query options via git config. 27 | .TP 28 | \fB\-\-no\-api\fR 29 | Don't use the GitHub REST API even if a personal access token is present at \fB~/.github-token\fR. 30 | .TP 31 | \fB\-G\fR, \fB\-\-no\-gpgsign\fR 32 | Do not automatically GPG-sign commits 33 | .TP 34 | \fB\-I\fR, \fB\-\-non-interactive\fR 35 | Do not interactively ask to merge, just do it." 36 | .TP 37 | \fB\-r\fR \fIREPO\fR, \fB\-\-repository\fR \fIREPO\fP 38 | GitHub repo to use (default: gentoo/gentoo) 39 | .TP 40 | \fB\-s\fR, \fB\-\-signoff\fR 41 | Add Signed-off-by to commits (the default) 42 | .TP 43 | \fB-S\fR, \fB\-\-no\-signoff\fR 44 | Disable adding Signed-off-by to commits 45 | .TP 46 | \fB\-p\fR, \fB\-\-part\-of\fR 47 | Add Part-of to commits, linking to the PR (the default) 48 | .TP 49 | \fB-P\fR, \fB\-\-no\-part\-of\fR 50 | Disable adding Part-of to commits 51 | .TP 52 | \fB\-\-link\-to \fIPULL_REQUEST\fR 53 | Override the pull request the merge is linked to. This will override the 54 | Part-of trailer, as well as the final Closes trailer. 55 | 56 | .SH PARAMETERS 57 | .IP \fI\fP 58 | GitHub PR number 59 | .IP \fI\fP 60 | Full URL to the pull request 61 | .IP \fI\fP 62 | URL to a patch file 63 | 64 | .SH GIT CONFIG SUPPORT 65 | PRam queries configuration via \fBgit config\fR by default. It makes it 66 | possible to specify additional options globally via \fB~/.gitconfig\fR 67 | and per-repo via \fB.git/config\fR. Command-line options override configuration 68 | files. 69 | 70 | The following options are currently supported: 71 | .TP 72 | string options: 73 | \fIpram.editor\fR, \fIpram.repo\fR 74 | .TP 75 | boolean options (\fB--type bool\fR): 76 | \fIpram.gpgsign\fR, \fIpram.interactive\fR, \fIpram.signoff\fR 77 | 78 | .SH GITHUB REST API SUPPORT 79 | PRam will use the GitHub REST API if a token is present at \fB~/.github-token\fR. 80 | 81 | .UR https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens 82 | See GitHub documentation on how to create one 83 | .UE . 84 | 85 | .SH LICENSE 86 | This program is free software; you can redistribute it and/or modify 87 | it under the terms of the GNU General Public License as published by 88 | the Free Software Foundation; either version 2 of the License, or 89 | (at your option) any later version. 90 | 91 | This program is distributed in the hope that it will be useful, 92 | but WITHOUT ANY WARRANTY; without even the implied warranty of 93 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 94 | GNU General Public License for more details. 95 | 96 | You should have received a copy of the GNU General Public License along 97 | with this program; if not, write to the Free Software Foundation, Inc., 98 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 99 | 100 | .SH AUTHOR 101 | .B PRam 102 | was written by Michał Górny 103 | -------------------------------------------------------------------------------- /test/00basic.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Test whether applying a plain patch via pram works. 3 | 4 | set -e -x 5 | 6 | . ./common-setup.sh 7 | 8 | cat > trivial.patch <<-EOF 9 | From 88460bc61f56546da478dc6fd4682e7c62cc6c80 Mon Sep 17 00:00:00 2001 10 | From: PRam test 11 | Date: Sat, 1 Jan 2000 00:00:00 +0000 12 | Subject: [PATCH] A trivial patch 13 | 14 | --- 15 | data.txt | 4 ++-- 16 | newfile.txt | 1 + 17 | 2 files changed, 3 insertions(+), 2 deletions(-) 18 | create mode 100644 newfile.txt 19 | 20 | diff --git a/data.txt b/data.txt 21 | index 5baade6..0139962 100644 22 | --- a/data.txt 23 | +++ b/data.txt 24 | @@ -1,8 +1,8 @@ 25 | This is some initial data. 26 | 27 | 001100 28 | -010010 29 | -011110 30 | 100001 31 | +011110 32 | +010010 33 | 101101 34 | 110011 35 | diff --git a/newfile.txt b/newfile.txt 36 | new file mode 100644 37 | index 0000000..6d8bf33 38 | --- /dev/null 39 | +++ b/newfile.txt 40 | @@ -0,0 +1 @@ 41 | +Also, a new file with CRLF line ending. 42 | -- 43 | 2.21.0 44 | EOF 45 | 46 | bash "${INITDIR}"/../pram --no-gitconfig -e true -G -I -S --link-to 123 ./trivial.patch 47 | 48 | git log --format='%ae%n%an%n%aI%n%B' -1 > git-log.txt 49 | diff -u - git-log.txt <<-EOF 50 | pram@example.com 51 | PRam test 52 | 2000-01-01T00:00:00Z 53 | A trivial patch 54 | 55 | Part-of: https://github.com/gentoo/gentoo/pull/123 56 | Closes: https://github.com/gentoo/gentoo/pull/123 57 | 58 | EOF 59 | sha1sum -c < trivial.patch <<-EOF 9 | From 88460bc61f56546da478dc6fd4682e7c62cc6c80 Mon Sep 17 00:00:00 2001 10 | From: Other person 11 | Date: Sat, 1 Jan 2000 00:00:00 +0000 12 | Subject: [PATCH] A trivial patch 13 | 14 | --- 15 | data.txt | 4 ++-- 16 | newfile.txt | 1 + 17 | 2 files changed, 3 insertions(+), 2 deletions(-) 18 | create mode 100644 newfile.txt 19 | 20 | diff --git a/data.txt b/data.txt 21 | index 5baade6..0139962 100644 22 | --- a/data.txt 23 | +++ b/data.txt 24 | @@ -1,8 +1,8 @@ 25 | This is some initial data. 26 | 27 | 001100 28 | -010010 29 | -011110 30 | 100001 31 | +011110 32 | +010010 33 | 101101 34 | 110011 35 | diff --git a/newfile.txt b/newfile.txt 36 | new file mode 100644 37 | index 0000000..6d8bf33 38 | --- /dev/null 39 | +++ b/newfile.txt 40 | @@ -0,0 +1 @@ 41 | +Also, a new file. 42 | -- 43 | 2.21.0 44 | EOF 45 | 46 | ! bash "${INITDIR}"/../pram --no-gitconfig -e true -G -I -s --link-to 123 ./trivial.patch 2> out.txt 47 | 48 | diff -u - out.txt <<-EOF 49 | Commit no. 0001 was not signed off by the author! 50 | EOF 51 | -------------------------------------------------------------------------------- /test/01signoff-partial.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Test whether a set of commits where only one is missing causes rejection. 3 | 4 | set -e -x 5 | 6 | . ./common-setup.sh 7 | 8 | cat > three-commits.patch <<-EOF 9 | From 243f5779c2ae9b0d117829b60fe7dbc466e968c0 Mon Sep 17 00:00:00 2001 10 | From: Other person 11 | Date: Sat, 1 Jan 2000 00:00:00 +0000 12 | Subject: [PATCH 1/3] First patch 13 | 14 | Signed-off-by: Other person 15 | 16 | --- 17 | data.txt | 2 +- 18 | 1 file changed, 1 insertion(+), 1 deletion(-) 19 | 20 | diff --git a/data.txt b/data.txt 21 | index 5baade6..a9a301d 100644 22 | --- a/data.txt 23 | +++ b/data.txt 24 | @@ -1,6 +1,6 @@ 25 | This is some initial data. 26 | 27 | -001100 28 | +001101 29 | 010010 30 | 011110 31 | 100001 32 | -- 33 | 2.49.0 34 | 35 | From 7aab19414dd17546985fd7c0091e779944e8f0df Mon Sep 17 00:00:00 2001 36 | From: Other person 37 | Date: Sat, 1 Jan 2000 00:00:00 +0000 38 | Subject: [PATCH 2/3] Second patch 39 | 40 | --- 41 | data.txt | 2 +- 42 | 1 file changed, 1 insertion(+), 1 deletion(-) 43 | 44 | diff --git a/data.txt b/data.txt 45 | index a9a301d..237b5ef 100644 46 | --- a/data.txt 47 | +++ b/data.txt 48 | @@ -1,7 +1,7 @@ 49 | This is some initial data. 50 | 51 | 001101 52 | -010010 53 | +010011 54 | 011110 55 | 100001 56 | 101101 57 | -- 58 | 2.49.0 59 | 60 | From 8be43d8aa258fd2c2cf25ec540d19ab6a25d4038 Mon Sep 17 00:00:00 2001 61 | From: Other person 62 | Date: Sat, 1 Jan 2000 00:00:00 +0000 63 | Subject: [PATCH 3/3] Third patch 64 | 65 | Signed-off-by: Other person 66 | 67 | --- 68 | data.txt | 2 +- 69 | 1 file changed, 1 insertion(+), 1 deletion(-) 70 | 71 | diff --git a/data.txt b/data.txt 72 | index 237b5ef..6ba7c31 100644 73 | --- a/data.txt 74 | +++ b/data.txt 75 | @@ -3,6 +3,6 @@ This is some initial data. 76 | 001101 77 | 010011 78 | 011110 79 | -100001 80 | +101101 81 | 101101 82 | 110011 83 | -- 84 | 2.49.0 85 | EOF 86 | 87 | ! bash "${INITDIR}"/../pram --no-gitconfig -e true -G -I -s -P ./three-commits.patch 2> out.txt 88 | 89 | diff -u - out.txt <<-EOF 90 | Commit no. 0002 was not signed off by the author! 91 | EOF 92 | -------------------------------------------------------------------------------- /test/01signoff-present.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Test whether signoff is properly verified and another one appended. 3 | 4 | set -e -x 5 | 6 | . ./common-setup.sh 7 | 8 | cat > trivial.patch <<-EOF 9 | From 88460bc61f56546da478dc6fd4682e7c62cc6c80 Mon Sep 17 00:00:00 2001 10 | From: Other person 11 | Date: Sat, 1 Jan 2000 00:00:00 +0000 12 | Subject: [PATCH] A trivial patch 13 | 14 | Signed-off-by: Other person 15 | 16 | --- 17 | data.txt | 4 ++-- 18 | newfile.txt | 1 + 19 | 2 files changed, 3 insertions(+), 2 deletions(-) 20 | create mode 100644 newfile.txt 21 | 22 | diff --git a/data.txt b/data.txt 23 | index 5baade6..0139962 100644 24 | --- a/data.txt 25 | +++ b/data.txt 26 | @@ -1,8 +1,8 @@ 27 | This is some initial data. 28 | 29 | 001100 30 | -010010 31 | -011110 32 | 100001 33 | +011110 34 | +010010 35 | 101101 36 | 110011 37 | diff --git a/newfile.txt b/newfile.txt 38 | new file mode 100644 39 | index 0000000..6d8bf33 40 | --- /dev/null 41 | +++ b/newfile.txt 42 | @@ -0,0 +1 @@ 43 | +Also, a new file. 44 | -- 45 | 2.21.0 46 | EOF 47 | 48 | bash "${INITDIR}"/../pram --no-gitconfig -e true -G -I -s -P ./trivial.patch 49 | 50 | git log --format='%ae%n%an%n%ce%n%cn%n%aI%n%B' -1 > git-log.txt 51 | diff -u - git-log.txt <<-EOF 52 | other@example.com 53 | Other person 54 | pram@example.com 55 | PRam test 56 | 2000-01-01T00:00:00Z 57 | A trivial patch 58 | 59 | Signed-off-by: Other person 60 | Signed-off-by: PRam test 61 | 62 | EOF 63 | sha1sum -c < trivial.patch <<-EOF 9 | From 88460bc61f56546da478dc6fd4682e7c62cc6c80 Mon Sep 17 00:00:00 2001 10 | From: PRam test 11 | Date: Sat, 1 Jan 2000 00:00:00 +0000 12 | Subject: [PATCH] A trivial patch 13 | 14 | --- 15 | data.txt | 4 ++-- 16 | newfile.txt | 1 + 17 | 2 files changed, 3 insertions(+), 2 deletions(-) 18 | create mode 100644 newfile.txt 19 | 20 | diff --git a/data.txt b/data.txt 21 | index 5baade6..0139962 100644 22 | --- a/data.txt 23 | +++ b/data.txt 24 | @@ -1,8 +1,8 @@ 25 | This is some initial data. 26 | 27 | 001100 28 | -010010 29 | -011110 30 | 100001 31 | +011110 32 | +010010 33 | 101101 34 | 110011 35 | diff --git a/newfile.txt b/newfile.txt 36 | new file mode 100644 37 | index 0000000..6d8bf33 38 | --- /dev/null 39 | +++ b/newfile.txt 40 | @@ -0,0 +1 @@ 41 | +Also, a new file. 42 | -- 43 | 2.21.0 44 | EOF 45 | 46 | bash "${INITDIR}"/../pram --no-gitconfig -e true -G -I -S -b 314152 -P ./trivial.patch 47 | 48 | git log --format='%ae%n%an%n%aI%n%B' -1 > git-log.txt 49 | diff -u - git-log.txt <<-EOF 50 | pram@example.com 51 | PRam test 52 | 2000-01-01T00:00:00Z 53 | A trivial patch 54 | 55 | Bug: https://bugs.gentoo.org/314152 56 | 57 | EOF 58 | sha1sum -c < trivial.patch <<-EOF 9 | From 88460bc61f56546da478dc6fd4682e7c62cc6c80 Mon Sep 17 00:00:00 2001 10 | From: PRam test 11 | Date: Sat, 1 Jan 2000 00:00:00 +0000 12 | Subject: [PATCH] A trivial patch 13 | 14 | --- 15 | data.txt | 4 ++-- 16 | newfile.txt | 1 + 17 | 2 files changed, 3 insertions(+), 2 deletions(-) 18 | create mode 100644 newfile.txt 19 | 20 | diff --git a/data.txt b/data.txt 21 | index 5baade6..0139962 100644 22 | --- a/data.txt 23 | +++ b/data.txt 24 | @@ -1,8 +1,8 @@ 25 | This is some initial data. 26 | 27 | 001100 28 | -010010 29 | -011110 30 | 100001 31 | +011110 32 | +010010 33 | 101101 34 | 110011 35 | diff --git a/newfile.txt b/newfile.txt 36 | new file mode 100644 37 | index 0000000..6d8bf33 38 | --- /dev/null 39 | +++ b/newfile.txt 40 | @@ -0,0 +1 @@ 41 | +Also, a new file. 42 | -- 43 | 2.21.0 44 | EOF 45 | 46 | bash "${INITDIR}"/../pram --no-gitconfig -e true -G -I -S -b https://bugs.example.com/123456 -P ./trivial.patch 47 | 48 | git log --format='%ae%n%an%n%aI%n%B' -1 > git-log.txt 49 | diff -u - git-log.txt <<-EOF 50 | pram@example.com 51 | PRam test 52 | 2000-01-01T00:00:00Z 53 | A trivial patch 54 | 55 | Bug: https://bugs.example.com/123456 56 | 57 | EOF 58 | sha1sum -c < trivial.patch <<-EOF 9 | From 88460bc61f56546da478dc6fd4682e7c62cc6c80 Mon Sep 17 00:00:00 2001 10 | From: PRam test 11 | Date: Sat, 1 Jan 2000 00:00:00 +0000 12 | Subject: [PATCH] A trivial patch 13 | 14 | --- 15 | data.txt | 4 ++-- 16 | newfile.txt | 1 + 17 | 2 files changed, 3 insertions(+), 2 deletions(-) 18 | create mode 100644 newfile.txt 19 | 20 | diff --git a/data.txt b/data.txt 21 | index 5baade6..0139962 100644 22 | --- a/data.txt 23 | +++ b/data.txt 24 | @@ -1,8 +1,8 @@ 25 | This is some initial data. 26 | 27 | 001100 28 | -010010 29 | -011110 30 | 100001 31 | +011110 32 | +010010 33 | 101101 34 | 110011 35 | diff --git a/newfile.txt b/newfile.txt 36 | new file mode 100644 37 | index 0000000..6d8bf33 38 | --- /dev/null 39 | +++ b/newfile.txt 40 | @@ -0,0 +1 @@ 41 | +Also, a new file. 42 | -- 43 | 2.21.0 44 | EOF 45 | 46 | bash "${INITDIR}"/../pram --no-gitconfig -e true -G -I -S -c 314152 -P ./trivial.patch 47 | 48 | git log --format='%ae%n%an%n%aI%n%B' -1 > git-log.txt 49 | diff -u - git-log.txt <<-EOF 50 | pram@example.com 51 | PRam test 52 | 2000-01-01T00:00:00Z 53 | A trivial patch 54 | 55 | Closes: https://bugs.gentoo.org/314152 56 | 57 | EOF 58 | sha1sum -c < trivial.patch <<-EOF 9 | From 88460bc61f56546da478dc6fd4682e7c62cc6c80 Mon Sep 17 00:00:00 2001 10 | From: PRam test 11 | Date: Sat, 1 Jan 2000 00:00:00 +0000 12 | Subject: [PATCH] A trivial patch 13 | 14 | --- 15 | data.txt | 4 ++-- 16 | newfile.txt | 1 + 17 | 2 files changed, 3 insertions(+), 2 deletions(-) 18 | create mode 100644 newfile.txt 19 | 20 | diff --git a/data.txt b/data.txt 21 | index 5baade6..0139962 100644 22 | --- a/data.txt 23 | +++ b/data.txt 24 | @@ -1,8 +1,8 @@ 25 | This is some initial data. 26 | 27 | 001100 28 | -010010 29 | -011110 30 | 100001 31 | +011110 32 | +010010 33 | 101101 34 | 110011 35 | diff --git a/newfile.txt b/newfile.txt 36 | new file mode 100644 37 | index 0000000..6d8bf33 38 | --- /dev/null 39 | +++ b/newfile.txt 40 | @@ -0,0 +1 @@ 41 | +Also, a new file. 42 | -- 43 | 2.21.0 44 | EOF 45 | 46 | bash "${INITDIR}"/../pram --no-gitconfig -e true -G -I -S -c https://bugs.example.com/123456 -P ./trivial.patch 47 | 48 | git log --format='%ae%n%an%n%aI%n%B' -1 > git-log.txt 49 | diff -u - git-log.txt <<-EOF 50 | pram@example.com 51 | PRam test 52 | 2000-01-01T00:00:00Z 53 | A trivial patch 54 | 55 | Closes: https://bugs.example.com/123456 56 | 57 | EOF 58 | sha1sum -c < trivial.patch <<-EOF 9 | From 88460bc61f56546da478dc6fd4682e7c62cc6c80 Mon Sep 17 00:00:00 2001 10 | From: PRam test 11 | Date: Sat, 1 Jan 2000 00:00:00 +0000 12 | Subject: [PATCH] A trivial patch 13 | 14 | --- 15 | data.txt | 4 ++-- 16 | newfile.txt | 1 + 17 | 2 files changed, 3 insertions(+), 2 deletions(-) 18 | create mode 100644 newfile.txt 19 | 20 | diff --git a/data.txt b/data.txt 21 | index 5baade6..0139962 100644 22 | --- a/data.txt 23 | +++ b/data.txt 24 | @@ -1,8 +1,8 @@ 25 | This is some initial data. 26 | 27 | 001100 28 | -010010 29 | -011110 30 | 100001 31 | +011110 32 | +010010 33 | 101101 34 | 110011 35 | diff --git a/newfile.txt b/newfile.txt 36 | new file mode 100644 37 | index 0000000..6d8bf33 38 | --- /dev/null 39 | +++ b/newfile.txt 40 | @@ -0,0 +1 @@ 41 | +Also, a new file. 42 | -- 43 | 2.21.0 44 | EOF 45 | 46 | bash "${INITDIR}"/../pram --no-gitconfig -e true -G -I -S -b 314152 -b 314156 -b 314154 -P ./trivial.patch 47 | 48 | git log --format='%ae%n%an%n%aI%n%B' -1 > git-log.txt 49 | diff -u - git-log.txt <<-EOF 50 | pram@example.com 51 | PRam test 52 | 2000-01-01T00:00:00Z 53 | A trivial patch 54 | 55 | Bug: https://bugs.gentoo.org/314152 56 | Bug: https://bugs.gentoo.org/314156 57 | Bug: https://bugs.gentoo.org/314154 58 | 59 | EOF 60 | sha1sum -c < trivial.patch <<-EOF 9 | From 88460bc61f56546da478dc6fd4682e7c62cc6c80 Mon Sep 17 00:00:00 2001 10 | From: PRam test 11 | Date: Sat, 1 Jan 2000 00:00:00 +0000 12 | Subject: [PATCH] A trivial patch 13 | 14 | --- 15 | data.txt | 4 ++-- 16 | newfile.txt | 1 + 17 | 2 files changed, 3 insertions(+), 2 deletions(-) 18 | create mode 100644 newfile.txt 19 | 20 | diff --git a/data.txt b/data.txt 21 | index 5baade6..0139962 100644 22 | --- a/data.txt 23 | +++ b/data.txt 24 | @@ -1,8 +1,8 @@ 25 | This is some initial data. 26 | 27 | 001100 28 | -010010 29 | -011110 30 | 100001 31 | +011110 32 | +010010 33 | 101101 34 | 110011 35 | diff --git a/newfile.txt b/newfile.txt 36 | new file mode 100644 37 | index 0000000..6d8bf33 38 | --- /dev/null 39 | +++ b/newfile.txt 40 | @@ -0,0 +1 @@ 41 | +Also, a new file. 42 | -- 43 | 2.21.0 44 | EOF 45 | 46 | bash "${INITDIR}"/../pram --no-gitconfig -e true -G -I -S -c 314152 -c 314156 -c 314154 -P ./trivial.patch 47 | 48 | git log --format='%ae%n%an%n%aI%n%B' -1 > git-log.txt 49 | diff -u - git-log.txt <<-EOF 50 | pram@example.com 51 | PRam test 52 | 2000-01-01T00:00:00Z 53 | A trivial patch 54 | 55 | Closes: https://bugs.gentoo.org/314152 56 | Closes: https://bugs.gentoo.org/314156 57 | Closes: https://bugs.gentoo.org/314154 58 | 59 | EOF 60 | sha1sum -c < trivial.patch <<-EOF 9 | From 88460bc61f56546da478dc6fd4682e7c62cc6c80 Mon Sep 17 00:00:00 2001 10 | From: PRam test 11 | Date: Sat, 1 Jan 2000 00:00:00 +0000 12 | Subject: [PATCH] A trivial patch 13 | 14 | --- 15 | data.txt | 4 ++-- 16 | newfile.txt | 1 + 17 | 2 files changed, 3 insertions(+), 2 deletions(-) 18 | create mode 100644 newfile.txt 19 | 20 | diff --git a/data.txt b/data.txt 21 | index 5baade6..0139962 100644 22 | --- a/data.txt 23 | +++ b/data.txt 24 | @@ -1,8 +1,8 @@ 25 | This is some initial data. 26 | 27 | 001100 28 | -010010 29 | -011110 30 | 100001 31 | +011110 32 | +010010 33 | 101101 34 | 110011 35 | diff --git a/newfile.txt b/newfile.txt 36 | new file mode 100644 37 | index 0000000..6d8bf33 38 | --- /dev/null 39 | +++ b/newfile.txt 40 | @@ -0,0 +1 @@ 41 | +Also, a new file. 42 | -- 43 | 2.21.0 44 | EOF 45 | 46 | bash "${INITDIR}"/../pram --no-gitconfig -e true -G -I -S -c 314152 -b 314156 -b 314154 -P ./trivial.patch 47 | 48 | git log --format='%ae%n%an%n%aI%n%B' -1 > git-log.txt 49 | diff -u - git-log.txt <<-EOF 50 | pram@example.com 51 | PRam test 52 | 2000-01-01T00:00:00Z 53 | A trivial patch 54 | 55 | Bug: https://bugs.gentoo.org/314156 56 | Bug: https://bugs.gentoo.org/314154 57 | Closes: https://bugs.gentoo.org/314152 58 | 59 | EOF 60 | sha1sum -c < trivial.patch <<-EOF 9 | From 88460bc61f56546da478dc6fd4682e7c62cc6c80 Mon Sep 17 00:00:00 2001 10 | From: Other person 11 | Date: Sat, 1 Jan 2000 00:00:00 +0000 12 | Subject: [PATCH] A trivial patch 13 | 14 | Signed-off-by: Other person 15 | --- 16 | data.txt | 4 ++-- 17 | newfile.txt | 1 + 18 | 2 files changed, 3 insertions(+), 2 deletions(-) 19 | create mode 100644 newfile.txt 20 | 21 | diff --git a/data.txt b/data.txt 22 | index 5baade6..0139962 100644 23 | --- a/data.txt 24 | +++ b/data.txt 25 | @@ -1,8 +1,8 @@ 26 | This is some initial data. 27 | 28 | 001100 29 | -010010 30 | -011110 31 | 100001 32 | +011110 33 | +010010 34 | 101101 35 | 110011 36 | diff --git a/newfile.txt b/newfile.txt 37 | new file mode 100644 38 | index 0000000..6d8bf33 39 | --- /dev/null 40 | +++ b/newfile.txt 41 | @@ -0,0 +1 @@ 42 | +Also, a new file. 43 | -- 44 | 2.21.0 45 | EOF 46 | 47 | bash "${INITDIR}"/../pram --no-gitconfig -e true -G -I -s -b 314152 -c 314154 -P ./trivial.patch 48 | 49 | git log --format='%ae%n%an%n%ce%n%cn%n%aI%n%B' -1 > git-log.txt 50 | diff -u - git-log.txt <<-EOF 51 | other@example.com 52 | Other person 53 | pram@example.com 54 | PRam test 55 | 2000-01-01T00:00:00Z 56 | A trivial patch 57 | 58 | Signed-off-by: Other person 59 | Bug: https://bugs.gentoo.org/314152 60 | Closes: https://bugs.gentoo.org/314154 61 | Signed-off-by: PRam test 62 | 63 | EOF 64 | sha1sum -c < trivial.patch <<-EOF 9 | From 88460bc61f56546da478dc6fd4682e7c62cc6c80 Mon Sep 17 00:00:00 2001 10 | From: PRam test 11 | Date: Sat, 1 Jan 2000 00:00:00 +0000 12 | Subject: [PATCH] A trivial patch 13 | 14 | --- 15 | data.txt | 4 ++-- 16 | newfile.txt | 1 + 17 | 2 files changed, 3 insertions(+), 2 deletions(-) 18 | create mode 100644 newfile.txt 19 | 20 | diff --git a/data.txt b/data.txt 21 | index 5baade6..0139962 100644 22 | --- a/data.txt 23 | +++ b/data.txt 24 | @@ -1,8 +1,8 @@ 25 | This is some initial data. 26 | 27 | 001100 28 | -010010 29 | -011110 30 | 100001 31 | +011110 32 | +010010 33 | 101101 34 | 110011 35 | diff --git a/newfile.txt b/newfile.txt 36 | new file mode 100644 37 | index 0000000..6d8bf33 38 | --- /dev/null 39 | +++ b/newfile.txt 40 | @@ -0,0 +1 @@ 41 | +Also, a new file. 42 | -- 43 | 2.21.0 44 | EOF 45 | 46 | BEFORE=$(git rev-parse HEAD) 47 | echo 'n' | bash "${INITDIR}"/../pram --no-gitconfig -e true -G -S -P ./trivial.patch 48 | 49 | [ "${BEFORE}" = "$(git rev-parse HEAD)" ] 50 | -------------------------------------------------------------------------------- /test/04interactive-yes.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Test interactive mode with 'yes' input. 3 | 4 | set -e -x 5 | 6 | . ./common-setup.sh 7 | 8 | cat > trivial.patch <<-EOF 9 | From 88460bc61f56546da478dc6fd4682e7c62cc6c80 Mon Sep 17 00:00:00 2001 10 | From: PRam test 11 | Date: Sat, 1 Jan 2000 00:00:00 +0000 12 | Subject: [PATCH] A trivial patch 13 | 14 | --- 15 | data.txt | 4 ++-- 16 | newfile.txt | 1 + 17 | 2 files changed, 3 insertions(+), 2 deletions(-) 18 | create mode 100644 newfile.txt 19 | 20 | diff --git a/data.txt b/data.txt 21 | index 5baade6..0139962 100644 22 | --- a/data.txt 23 | +++ b/data.txt 24 | @@ -1,8 +1,8 @@ 25 | This is some initial data. 26 | 27 | 001100 28 | -010010 29 | -011110 30 | 100001 31 | +011110 32 | +010010 33 | 101101 34 | 110011 35 | diff --git a/newfile.txt b/newfile.txt 36 | new file mode 100644 37 | index 0000000..6d8bf33 38 | --- /dev/null 39 | +++ b/newfile.txt 40 | @@ -0,0 +1 @@ 41 | +Also, a new file. 42 | -- 43 | 2.21.0 44 | EOF 45 | 46 | echo 'y' | bash "${INITDIR}"/../pram --no-gitconfig -e true -G -S -P ./trivial.patch 47 | 48 | git log --format='%ae%n%an%n%aI%n%B' -1 > git-log.txt 49 | diff -u - git-log.txt <<-EOF 50 | pram@example.com 51 | PRam test 52 | 2000-01-01T00:00:00Z 53 | A trivial patch 54 | 55 | EOF 56 | sha1sum -c < trivial.patch <<-EOF 9 | From 88460bc61f56546da478dc6fd4682e7c62cc6c80 Mon Sep 17 00:00:00 2001 10 | From: PRam test 11 | Date: Sat, 1 Jan 2000 00:00:00 +0000 12 | Subject: [PATCH] A trivial patch 13 | 14 | --- 15 | data.txt | 4 ++-- 16 | newfile.txt | 1 + 17 | 2 files changed, 3 insertions(+), 2 deletions(-) 18 | create mode 100644 newfile.txt 19 | 20 | diff --git a/data.txt b/data.txt 21 | index 5baade6..0139962 100644 22 | --- a/data.txt 23 | +++ b/data.txt 24 | @@ -1,8 +1,8 @@ 25 | This is some initial data. 26 | 27 | 001100 28 | -010010 29 | -011110 30 | 100001 31 | +011110 32 | +010010 33 | 101101 34 | 110011 35 | diff --git a/newfile.txt b/newfile.txt 36 | new file mode 100644 37 | index 0000000..6d8bf33 38 | --- /dev/null 39 | +++ b/newfile.txt 40 | @@ -0,0 +1 @@ 41 | +Also, a new file. 42 | -- 43 | 2.21.0 44 | EOF 45 | 46 | BEFORE=$(git rev-parse HEAD) 47 | bash "${INITDIR}"/../pram --no-gitconfig -e 'truncate -s 0' -G -I -S -P ./trivial.patch 48 | 49 | [ "${BEFORE}" = "$(git rev-parse HEAD)" ] 50 | -------------------------------------------------------------------------------- /test/05editor-fail.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Test whether file failed editor prevents applying. 3 | 4 | set -e -x 5 | 6 | . ./common-setup.sh 7 | 8 | cat > trivial.patch <<-EOF 9 | From 88460bc61f56546da478dc6fd4682e7c62cc6c80 Mon Sep 17 00:00:00 2001 10 | From: PRam test 11 | Date: Sat, 1 Jan 2000 00:00:00 +0000 12 | Subject: [PATCH] A trivial patch 13 | 14 | --- 15 | data.txt | 4 ++-- 16 | newfile.txt | 1 + 17 | 2 files changed, 3 insertions(+), 2 deletions(-) 18 | create mode 100644 newfile.txt 19 | 20 | diff --git a/data.txt b/data.txt 21 | index 5baade6..0139962 100644 22 | --- a/data.txt 23 | +++ b/data.txt 24 | @@ -1,8 +1,8 @@ 25 | This is some initial data. 26 | 27 | 001100 28 | -010010 29 | -011110 30 | 100001 31 | +011110 32 | +010010 33 | 101101 34 | 110011 35 | diff --git a/newfile.txt b/newfile.txt 36 | new file mode 100644 37 | index 0000000..6d8bf33 38 | --- /dev/null 39 | +++ b/newfile.txt 40 | @@ -0,0 +1 @@ 41 | +Also, a new file. 42 | -- 43 | 2.21.0 44 | EOF 45 | 46 | BEFORE=$(git rev-parse HEAD) 47 | ! bash "${INITDIR}"/../pram --no-gitconfig -e false -G -I -S ./trivial.patch 48 | 49 | [ "${BEFORE}" = "$(git rev-parse HEAD)" ] 50 | -------------------------------------------------------------------------------- /test/06gpgsign.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Test GPG-signing. 3 | 4 | set -e -x 5 | 6 | . ./common-setup.sh 7 | 8 | # Generate a temporary key. 9 | export GNUPGHOME=${TMPDIR}/gpg 10 | mkdir "${GNUPGHOME}" 11 | gpg --batch --passphrase '' --quick-generate-key 'PRam test ' || exit 77 12 | git config --local user.signingkey pram@example.com 13 | 14 | cat > trivial.patch <<-EOF 15 | From 88460bc61f56546da478dc6fd4682e7c62cc6c80 Mon Sep 17 00:00:00 2001 16 | From: PRam test 17 | Date: Sat, 1 Jan 2000 00:00:00 +0000 18 | Subject: [PATCH] A trivial patch 19 | 20 | --- 21 | data.txt | 4 ++-- 22 | newfile.txt | 1 + 23 | 2 files changed, 3 insertions(+), 2 deletions(-) 24 | create mode 100644 newfile.txt 25 | 26 | diff --git a/data.txt b/data.txt 27 | index 5baade6..0139962 100644 28 | --- a/data.txt 29 | +++ b/data.txt 30 | @@ -1,8 +1,8 @@ 31 | This is some initial data. 32 | 33 | 001100 34 | -010010 35 | -011110 36 | 100001 37 | +011110 38 | +010010 39 | 101101 40 | 110011 41 | diff --git a/newfile.txt b/newfile.txt 42 | new file mode 100644 43 | index 0000000..6d8bf33 44 | --- /dev/null 45 | +++ b/newfile.txt 46 | @@ -0,0 +1 @@ 47 | +Also, a new file. 48 | -- 49 | 2.21.0 50 | EOF 51 | 52 | bash "${INITDIR}"/../pram --no-gitconfig -e true -I -S -P ./trivial.patch 53 | 54 | git log --format='%ae%n%an%n%aI%n%G?%n%B' -1 > git-log.txt 55 | diff -u - git-log.txt <<-EOF 56 | pram@example.com 57 | PRam test 58 | 2000-01-01T00:00:00Z 59 | G 60 | A trivial patch 61 | 62 | EOF 63 | sha1sum -c < trivial.patch <<-EOF 13 | From 88460bc61f56546da478dc6fd4682e7c62cc6c80 Mon Sep 17 00:00:00 2001 14 | From: PRam test 15 | Date: Sat, 1 Jan 2000 00:00:00 +0000 16 | Subject: [PATCH] A trivial patch 17 | 18 | --- 19 | data.txt | 4 ++-- 20 | newfile.txt | 1 + 21 | 2 files changed, 3 insertions(+), 2 deletions(-) 22 | create mode 100644 newfile.txt 23 | 24 | diff --git a/data.txt b/data.txt 25 | index 5baade6..0139962 100644 26 | --- a/data.txt 27 | +++ b/data.txt 28 | @@ -1,8 +1,8 @@ 29 | This is some initial data. 30 | 31 | 001100 32 | -010010 33 | -011110 34 | 100001 35 | +011110 36 | +010010 37 | 101101 38 | 110011 39 | diff --git a/newfile.txt b/newfile.txt 40 | new file mode 100644 41 | index 0000000..6d8bf33 42 | --- /dev/null 43 | +++ b/newfile.txt 44 | @@ -0,0 +1 @@ 45 | +Also, a new file. 46 | -- 47 | 2.21.0 48 | EOF 49 | 50 | BEFORE=$(git rev-parse HEAD) 51 | ! bash "${INITDIR}"/../pram --no-gitconfig -e true -G -I -S --am-options '--no-3way' ./trivial.patch 52 | 53 | [ "${BEFORE}" = "$(git rev-parse HEAD)" ] 54 | -------------------------------------------------------------------------------- /test/10threeway.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Test whether a patch needing 3-way merge works. 3 | 4 | set -e -x 5 | 6 | . ./common-setup.sh 7 | 8 | sed -i -e '2i Some rogue text in here.' data.txt 9 | git add data.txt 10 | git commit -m 'Rogue commit' 11 | 12 | cat > trivial.patch <<-EOF 13 | From 88460bc61f56546da478dc6fd4682e7c62cc6c80 Mon Sep 17 00:00:00 2001 14 | From: PRam test 15 | Date: Sat, 1 Jan 2000 00:00:00 +0000 16 | Subject: [PATCH] A trivial patch 17 | 18 | --- 19 | data.txt | 4 ++-- 20 | newfile.txt | 1 + 21 | 2 files changed, 3 insertions(+), 2 deletions(-) 22 | create mode 100644 newfile.txt 23 | 24 | diff --git a/data.txt b/data.txt 25 | index 5baade6..0139962 100644 26 | --- a/data.txt 27 | +++ b/data.txt 28 | @@ -1,8 +1,8 @@ 29 | This is some initial data. 30 | 31 | 001100 32 | -010010 33 | -011110 34 | 100001 35 | +011110 36 | +010010 37 | 101101 38 | 110011 39 | diff --git a/newfile.txt b/newfile.txt 40 | new file mode 100644 41 | index 0000000..6d8bf33 42 | --- /dev/null 43 | +++ b/newfile.txt 44 | @@ -0,0 +1 @@ 45 | +Also, a new file. 46 | -- 47 | 2.21.0 48 | EOF 49 | 50 | bash "${INITDIR}"/../pram --no-gitconfig -e true -G -I -S -P ./trivial.patch 51 | 52 | git log --format='%ae%n%an%n%aI%n%B' -1 > git-log.txt 53 | diff -u - git-log.txt <<-EOF 54 | pram@example.com 55 | PRam test 56 | 2000-01-01T00:00:00Z 57 | A trivial patch 58 | 59 | EOF 60 | sha1sum -c < trivial.patch <<-EOF 10 | From 88460bc61f56546da478dc6fd4682e7c62cc6c80 Mon Sep 17 00:00:00 2001 11 | From: Other person 12 | Date: Sat, 1 Jan 2000 00:00:00 +0000 13 | Subject: [PATCH] A trivial patch 14 | 15 | Signed-off-by: Other person 16 | --- 17 | data.txt | 4 ++-- 18 | newfile.txt | 1 + 19 | 2 files changed, 3 insertions(+), 2 deletions(-) 20 | create mode 100644 newfile.txt 21 | 22 | diff --git a/data.txt b/data.txt 23 | index 5baade6..0139962 100644 24 | --- a/data.txt 25 | +++ b/data.txt 26 | @@ -1,8 +1,8 @@ 27 | This is some initial data. 28 | 29 | 001100 30 | -010010 31 | -011110 32 | 100001 33 | +011110 34 | +010010 35 | 101101 36 | 110011 37 | diff --git a/newfile.txt b/newfile.txt 38 | new file mode 100644 39 | index 0000000..6d8bf33 40 | --- /dev/null 41 | +++ b/newfile.txt 42 | @@ -0,0 +1 @@ 43 | +Also, a new file. 44 | -- 45 | 2.21.0 46 | EOF 47 | 48 | bash "${INITDIR}"/../pram --no-gitconfig -e true -G -I -s -b 314152 -c 314154 --link-to 123 ./trivial.patch 49 | 50 | git log --format='%ae%n%an%n%ce%n%cn%n%aI%n%B' -1 > git-log.txt 51 | diff -u - git-log.txt <<-EOF 52 | other@example.com 53 | Other person 54 | pram@example.com 55 | PRam test 56 | 2000-01-01T00:00:00Z 57 | A trivial patch 58 | 59 | Signed-off-by: Other person 60 | Part-of: https://github.com/gentoo/gentoo/pull/123 61 | Bug: https://bugs.gentoo.org/314152 62 | Closes: https://bugs.gentoo.org/314154 63 | Closes: https://github.com/gentoo/gentoo/pull/123 64 | Signed-off-by: PRam test 65 | 66 | EOF 67 | sha1sum -c < three-commits.patch <<-EOF 9 | From 243f5779c2ae9b0d117829b60fe7dbc466e968c0 Mon Sep 17 00:00:00 2001 10 | From: PRam test 11 | Date: Sat, 1 Jan 2000 00:00:00 +0000 12 | Subject: [PATCH 1/3] First patch 13 | 14 | --- 15 | data.txt | 2 +- 16 | 1 file changed, 1 insertion(+), 1 deletion(-) 17 | 18 | diff --git a/data.txt b/data.txt 19 | index 5baade6..a9a301d 100644 20 | --- a/data.txt 21 | +++ b/data.txt 22 | @@ -1,6 +1,6 @@ 23 | This is some initial data. 24 | 25 | -001100 26 | +001101 27 | 010010 28 | 011110 29 | 100001 30 | -- 31 | 2.49.0 32 | 33 | From 7aab19414dd17546985fd7c0091e779944e8f0df Mon Sep 17 00:00:00 2001 34 | From: PRam test 35 | Date: Sat, 1 Jan 2000 00:00:00 +0000 36 | Subject: [PATCH 2/3] Second patch 37 | 38 | --- 39 | data.txt | 2 +- 40 | 1 file changed, 1 insertion(+), 1 deletion(-) 41 | 42 | diff --git a/data.txt b/data.txt 43 | index a9a301d..237b5ef 100644 44 | --- a/data.txt 45 | +++ b/data.txt 46 | @@ -1,7 +1,7 @@ 47 | This is some initial data. 48 | 49 | 001101 50 | -010010 51 | +010011 52 | 011110 53 | 100001 54 | 101101 55 | -- 56 | 2.49.0 57 | 58 | From 8be43d8aa258fd2c2cf25ec540d19ab6a25d4038 Mon Sep 17 00:00:00 2001 59 | From: PRam test 60 | Date: Sat, 1 Jan 2000 00:00:00 +0000 61 | Subject: [PATCH 3/3] Third patch 62 | 63 | --- 64 | data.txt | 2 +- 65 | 1 file changed, 1 insertion(+), 1 deletion(-) 66 | 67 | diff --git a/data.txt b/data.txt 68 | index 237b5ef..6ba7c31 100644 69 | --- a/data.txt 70 | +++ b/data.txt 71 | @@ -3,6 +3,6 @@ This is some initial data. 72 | 001101 73 | 010011 74 | 011110 75 | -100001 76 | +101101 77 | 101101 78 | 110011 79 | -- 80 | 2.49.0 81 | EOF 82 | 83 | # We use `--link-to 123` in a couple other tests, but there's another way we should test 84 | bash "${INITDIR}"/../pram --no-gitconfig -e true -G -I -S --link-to https://github.com/gentoo/gentoo/pull/123 ./three-commits.patch 85 | 86 | git log --format='%ae%n%an%n%aI%n%B' -3 > git-log.txt 87 | diff -u - git-log.txt <<-EOF 88 | pram@example.com 89 | PRam test 90 | 2000-01-01T00:00:00Z 91 | Third patch 92 | 93 | Part-of: https://github.com/gentoo/gentoo/pull/123 94 | Closes: https://github.com/gentoo/gentoo/pull/123 95 | 96 | pram@example.com 97 | PRam test 98 | 2000-01-01T00:00:00Z 99 | Second patch 100 | 101 | Part-of: https://github.com/gentoo/gentoo/pull/123 102 | 103 | pram@example.com 104 | PRam test 105 | 2000-01-01T00:00:00Z 106 | First patch 107 | 108 | Part-of: https://github.com/gentoo/gentoo/pull/123 109 | 110 | EOF 111 | sha256sum -c <<-EOF 112 | c95bc3022ee967e117fc7841d9b6597e672d7ef1da7897b2c2692fe8b099911d data.txt 113 | EOF 114 | -------------------------------------------------------------------------------- /test/common-setup.sh: -------------------------------------------------------------------------------- 1 | # (this is intended to be sourced from other tests) 2 | 3 | INITDIR=${PWD} 4 | TMPDIR=$(mktemp -d) 5 | trap 'rm -r -f "${TMPDIR}"' EXIT 6 | 7 | # Use predefined timestamp to get reproducible repo. 8 | export GIT_AUTHOR_DATE='2000-01-01 00:00:00Z' 9 | export GIT_COMMITTER_DATE='2000-01-01 00:00:00Z' 10 | 11 | cd "${TMPDIR}" 12 | git init 13 | git config --local user.name 'PRam test' 14 | git config --local user.email 'pram@example.com' 15 | cat > data.txt <<-EOF 16 | This is some initial data. 17 | 18 | 001100 19 | 010010 20 | 011110 21 | 100001 22 | 101101 23 | 110011 24 | EOF 25 | git add data.txt 26 | git commit -m 'Initial commit' 27 | --------------------------------------------------------------------------------