Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename git formatted patch to some nice name #58

Open
voxik opened this issue Sep 1, 2023 · 1 comment
Open

Rename git formatted patch to some nice name #58

voxik opened this issue Sep 1, 2023 · 1 comment

Comments

@voxik
Copy link

voxik commented Sep 1, 2023

Packaging SW for Fedora, I sometimes need to apply patch, which I'll download from GH, e.g.:

$ curl -OL https://github.com/rails/sprockets/pull/791.patch
   % Total    % Received % Xferd  Average Speed   Time    Time Time  Current
                                  Dload  Upload   Total   Spent Left  Speed
   0     0    0     0    0     0      0      0 --:--:-- --:--:-- 
--:--:--     0
100 12717    0 12717    0     0  21765      0 --:--:-- --:--:-- --:--:-- 
58603

The problem with this is that I end up with the "791.patch" file, while I'd like have a file with similar name as if I have used the git command:

$ git format-patch -1 6554b6d
0001-Fix-Minitest-constant-name-in-tests.patch

So I wonder, would you consider to implement some tool, which would renamed the patch in this way?

I have originally tried to convince Git folks to expose such functionality somewhere, but I failed :/ So maybe this project might be interested in this.

@voxik
Copy link
Author

voxik commented Sep 1, 2023

This is my naive implementation:

$ cat rename-patch 
#!/usr/bin/bash

mv $1 $(sed -ne '/^Subject: /{
        s/^Subject: *\[PATCH[^]]*\] *//;
        s/[^a-zA-Z0-9]/-/g;
        s/--*/-/g;
        s/$/\.patch/;
        p;
        q;
}' $1)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant