File: sync-manpages-with-help-output.sh

package info (click to toggle)
git-delete-merged-branches 7.5.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 300 kB
  • sloc: python: 1,843; sh: 26; makefile: 2
file content (44 lines) | stat: -rwxr-xr-x 1,495 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#! /usr/bin/env bash
# Copyright (C) 2022 Sebastian Pipping <sebastian@pipping.org>
# Licensed under GPL v3 or later

set -e
set -o pipefail

_BUILD_MONTH=2025-03  # for reproducible builds; bump when doing releases

sed_args=(
    # Produce familiar section "synopsis"
    -e 's,^\.SH DESCRIPTION,.SH SYNOPSIS,'
    -e 's,^usage: ,,'
    -e 's,.*\[\\-\\-yes\]$,\0\n.SH DESCRIPTION,'

    # Repair usage line bugs
    -e 's,\]\\fR,\\fR\\],'                       # un-colorize closing square bracket
    -e 's,\[\(\\-\\-[a-z\\-]\+\),[\\fB\1\\fR,g'  # colorize --argument in brackets

    # Be robust towards version difference between local help2man and CI help2man
    -e 's,It was generated by help2man .*,It was generated by help2man.,'

    # Put epilog in its own section
    -e 's,^Software libre.*,.SH EPILOG\n\0,'

    # Format "git-delete-merged-branches" in bold everywhere after section "NAME"
    -e 's,\(^\| \)\(git\\-\(delete\\-merged\\-branches\|dmb\)\) ,\n.B \2\n,g'

    # Un-colorize --merged in "git branch --merged"
    -e 's,git branch \\fB\\-\\-merged\\fR,git branch \\-\\-merged,'
)

for i in git-delete-merged-branches git-dmb ; do
    SOURCE_DATE_EPOCH="$(date --date="${_BUILD_MONTH}-15" +%s)" \
        NO_COLOR=please \
        COLUMNS=400 \
        help2man \
            --locale='en_US.UTF-8' \
            --no-info \
            --name 'Command-line tool to delete merged Git branches' \
            ${i} \
        | sed "${sed_args[@]}" \
        > ${i}.1
done