Debian Codegraph @

script/changelog

raw symbols SCIP
1 #!/usr/bin/envscip-shell filesystem . . `/usr/bin/env`. bash
2 #
3 # Interactively generates a changelog over a range of commits:
4
5 commit_summaryscip-shell shell shell-project 0.0.0 commit_summary().() {
6 local hash="$1"
7
8 pr=$(gitscip-shell system . . git. show $hash | grepscip-shell system . . grep. -o "#\([0-9]*\)" | cutscip-shell system . . cut. -c 2-)
9 prjson="$(curlscip-shell system . . curl. -n https://api.github.com/repos/git-lfs/git-lfs/pulls/$pr 2>/dev/nullscip-shell filesystem . . `/dev/null`.)"
10 title="$(echoscip-shell system . . echo. $prjson | jqscip-shell system . . jq. -r -e ".title")"
11 id="$(echoscip-shell system . . echo. $prjson | jqscip-shell system . . jq. -r -e ".number")"
12 author="$(echoscip-shell system . . echo. $prjson | jqscip-shell system . . jq. -r -e ".user.login")"
13
14 # If the title begins with "Backport", then strip everything until the actual
15 # pull-request title.
16 if grepscip-shell system . . grep. -q "Backport" <(echoscip-shell system . . echo. $title); then
17 title="$(echoscip-shell system . . echo. $title | sedscip-shell system . . sed. 's/^[^:]*: //g')"
18 fi
19
20 echoscip-shell system . . echo. "* $title #$id (@$author)"
21 }
22
23 revisions_inscip-shell shell shell-project 0.0.0 revisions_in(). () {
24 if [scip-shell system . . `[`. "$patch" -eq 1 ]; then
25 gitscip-shell system . . git. rev-list --first-parent "$1"
26 else
27 gitscip-shell system . . git. rev-list --merges --first-parent "$1"
28 fi
29 }
30
31 noninteractivescip-shell shell shell-project 0.0.0 noninteractive(). () {
32 local range="$1"
33
34 printfscip-shell system . . printf. '### Uncategorized\n'
35 for rev in $(revisions_inscip-shell shell shell-project 0.0.0 revisions_in(). "$range"); do
36 commit_summaryscip-shell shell shell-project 0.0.0 commit_summary(). $rev
37 done
38 catscip-shell system . . cat. <<-EOF
39
40 ### Features
41
42 ### Bugs
43
44 ### Misc
45 EOF
46 }
47
48 if [scip-shell system . . `[`. "$1" = "--noninteractive" ]; then
49 noninteractive=1
50 shift
51 fi
52
53 if [scip-shell system . . `[`. "$1" = "--patch" ]; then
54 patch=1
55 shift
56 else
57 patch=0
58 fi
59
60 range="$1"
61
62 if [scip-shell system . . `[`. "$range" = "" ]; then
63 echoscip-shell system . . echo. "Usage: $0 [options] base..next"
64 exit 1
65 fi
66
67 if [scip-shell system . . `[`. -n "$noninteractive" ]
68 then
69 noninteractivescip-shell shell shell-project 0.0.0 noninteractive(). "$range"
70 exit
71 fi
72
73 features=""
74 bugs=""
75 misc=""
76
77 for rev in $(revisions_inscip-shell shell shell-project 0.0.0 revisions_in(). "$range"); do
78 gitscip-shell system . . git. show -s $rev
79
80 processed=0
81 while [scip-shell system . . `[`. $processed -eq 0 ]; do
82 echoscip-shell system . . echo. "Categorize this change: [f,b,m,s,?] ?"
83 read -n 1 opt
84 echoscip-shell system . . echo. ""
85
86 case $opt in
87 [fbms])
88 processed=1
89 ;;
90 ?)
91 echoscip-shell system . . echo. "f - mark this merge as a feature"
92 echoscip-shell system . . echo. "b - mark this merge as a bugfix"
93 echoscip-shell system . . echo. "m - make this merge as a misc. change"
94 echoscip-shell system . . echo. "s - skip this merge, excluding it from the changelog"
95 echoscip-shell system . . echo. "? - display this help message"
96 ;;
97 *)
98 echoscip-shell system . . echo. "Unknown option: $opt, try again."
99 ;;
100 esac
101 done
102
103 if [scip-shell system . . `[`. $opt != "s" ]; then
104 summary="$(commit_summaryscip-shell shell shell-project 0.0.0 commit_summary(). $rev)"
105 fi
106
107 case $opt in
108 f)
109 features="$(printfscip-shell system . . printf. "%s\n%s\n" "$features" "$summary")"
110 ;;
111 b)
112 bugs="$(printfscip-shell system . . printf. "%s\n%s\n" "$bugs" "$summary")"
113 ;;
114 m)
115 misc="$(printfscip-shell system . . printf. "%s\n%s\n" "$misc" "$summary")"
116 ;;
117 esac
118 done
119
120 echoscip-shell system . . echo. "" >&2
121
122 catscip-shell system . . cat. <<- EOF
123 ### Features
124 $features
125
126 ### Bugs
127 $bugs
128
129 ### Misc
130 $misc
131 EOF