Skip to content

Commit

Permalink
scripts/release-notes: report missing RNs, don't skip standalone commits
Browse files Browse the repository at this point in the history
Prior to this patch, the release note script would skip over
standalone commits (without a PR) when extracting release notes.
This was defective, as the git history does have a few example
standalone commits, with release note but without PR.

Additionally, the script now reports PRs that are missing release
notes *or only use 'Release note: none'*, which may indicate
that the engineer did not bother filling in a note despite the
presence of a user-facing change.

For example:

```
$ python3 scripts/release-notes.py \
    --from v19.2.0-beta.20190930 \
    --until provisional_201911080435_v19.2.0-rc.5
```

Outputs (snippet):

- Andrei Matei:
  - 2019-10-04 [cockroachdb#41303][cockroachdb#41303] [ca32e6f][ca32e6f] sql: remove dead code [NO RELEASE NOTE]
  - 2019-10-05 [cockroachdb#41307][cockroachdb#41307] [1c99165][1c99165] sql: fix various problematic uses of the txn in DistSQL flows (4 commits)
  - 2019-10-28 [cockroachdb#41935][cockroachdb#41935] [bad8e55][bad8e55] settings/cluster: introducing the 19.2 cluster version [NO RELEASE NOTE]

In this example, the first PR has no release note but does not deserve
one. The second has a release note. The third is marked with "Release
note: None" but **there should really have been a release note**: the
introduction of the major cluster version is an important user-facing
change and should be announced.

By highlighting the missing release notes in this way, the script
gives an opportunity to the doc writer(s) to find additional
user-facing changes that need to be documented.

[cockroachdb#41303]: cockroachdb#41303
[cockroachdb#41307]: cockroachdb#41307
[cockroachdb#41935]: cockroachdb#41935
[ca32e6f]: cockroachdb@ca32e6ff0
[1c99165]: cockroachdb@1c99165c3
[bad8e55]: cockroachdb@bad8e55bb

Release note: None
  • Loading branch information
knz committed Nov 12, 2019
1 parent 627a76c commit 3d6f729
Show file tree
Hide file tree
Showing 14 changed files with 122 additions and 42 deletions.
56 changes: 42 additions & 14 deletions scripts/release-notes.py
Original file line number Diff line number Diff line change
Expand Up @@ -584,7 +584,6 @@ def extract_release_notes(commit):
_, notes = extract_release_notes(c)
for cat, note in notes:
excluded_notes.add((cat, note))

print("\b100%\n", file=sys.stderr)

print("Collecting release notes from\n%s\nuntil\n%s" % (identify_commit(firstCommit), identify_commit(commit)), file=sys.stderr)
Expand Down Expand Up @@ -626,7 +625,7 @@ def process_release_notes(pr, title, commit):
if not foundnote:
# Missing release note. Keep track for later.
missing_item = makeitem(pr, '', title, commit.hexsha[:shamin], authors)
return missing_item, authors
return missing_item, authors, len(notes)


def makeitem(pr, cat, prtitle, sha, authors):
Expand Down Expand Up @@ -741,6 +740,8 @@ def analyze_pr(merge, pr):
missing_items = []
authors = set()
ncommits = 0
num_notes = 0
commits_no_note = 0
for commit in repo.iter_commits(merge_base.hexsha + '..' + tip.hexsha):
spin()

Expand All @@ -753,9 +754,12 @@ def analyze_pr(merge, pr):
commit_to_pr[commit.hexsha[:shamin]] = pr

if not commit.message.startswith("Merge"):
missing_item, prauthors = process_release_notes(pr, note, commit)
missing_item, prauthors, num_notes1 = process_release_notes(pr, note, commit)
authors.update(prauthors)
ncommits += 1
num_notes += num_notes1
if num_notes == 0:
commits_no_note += 1
if missing_item is not None:
missing_items.append(missing_item)

Expand All @@ -767,10 +771,12 @@ def analyze_pr(merge, pr):
text = repo.git.diff(merge_base.hexsha, tip.hexsha, '--', numstat=True)
stats = Stats._list_from_string(repo, text)

collect_item(pr, note, merge.hexsha[:shamin], ncommits, authors, stats.total, merge.committed_date)
collect_item(pr, note, merge.hexsha[:shamin], ncommits, authors,
stats.total, merge.committed_date,
commits_no_note, num_notes == 0)


def collect_item(pr, prtitle, sha, ncommits, authors, stats, prts):
def collect_item(pr, prtitle, sha, ncommits, authors, stats, prts, ncommits_missing_note, pr_missing_note):
individual_authors.update(authors)
if len(authors) == 0:
authors.add("Unknown Author")
Expand All @@ -781,6 +787,8 @@ def collect_item(pr, prtitle, sha, ncommits, authors, stats, prts):
'files': stats['files'],
'lines': stats['lines'],
'date': datetime.date.fromtimestamp(prts).isoformat(),
'pr_missing_note': pr_missing_note,
'ncommits_missing_note': ncommits_missing_note,
})

al = item['authors']
Expand All @@ -790,14 +798,19 @@ def collect_item(pr, prtitle, sha, ncommits, authors, stats, prts):
per_group_history[k] = history


all_standalone_commits = set()
def analyze_standalone_commit(commit):
# Some random out-of-branch commit. Let's not forget them.
authors = collect_authors(commit)
title = commit.message.split('\n',1)[0].strip()
title = commit.message.split('\n', 1)[0].strip()
sha = commit.hexsha[:shamin]
item = makeitem('#unknown', '', title, sha, authors)
missing_release_notes.append(item)
collect_item('#unknown', title, sha, 1, authors, commit.stats.total, commit.committed_date)
all_standalone_commits.add(sha)
missing_item, authors, num_notes = process_release_notes("#unknown", title, commit)
if missing_item is not None:
missing_release_notes.append(missing_item)
commit_no_notes = num_notes == 0 and 1 or 0
collect_item('#unknown', title, sha, 1, authors,
commit.stats.total, commit.committed_date,
commit_no_notes, num_notes == 0)
commit_to_pr[sha] = '#unknown'

# Collect all the merge points so we can report progress.
Expand Down Expand Up @@ -1025,10 +1038,22 @@ def output_note(item):
## Print the Contributors section.
print("### Contributors")
print()
print("This release includes %d merged PR%s by %s author%s." %
(len(allprs), len(allprs) != 1 and "s" or "",
len(individual_authors), (len(individual_authors) != 1 and "s" or ""),
))
print("This release includes ", end='')
if len(allprs) > 0:
print("%d merged PR%s" %
(len(allprs),
len(allprs) != 1 and "s" or ""),
end='')
if len(all_standalone_commits) > 0:
print(" and ", end='')
if len(all_standalone_commits) > 0:
print("%d standalone commit%s" %
(len(all_standalone_commits),
len(all_standalone_commits) != 1 and "s" or ""),
end='')
print(" by %s author%s." % (
len(individual_authors),
(len(individual_authors) != 1 and "s" or "")))

ext_contributors = individual_authors - crdb_folk

Expand Down Expand Up @@ -1070,6 +1095,9 @@ def output_note(item):
print(" (", end='')
print("%d commits" % ncommits, end='')
print(")", end='')

if item['pr_missing_note']:
print(" [NO RELEASE NOTE]", end='')
print()
print()
print()
Expand Down
2 changes: 1 addition & 1 deletion scripts/release-notes/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ function test_init() {
# Initialize the repository. Tag the initial commit.
function init_repo() {
git init
mkdir -p .git/refs/pull/origin
touch foo; git add foo; git commit "${flags[@]}" -m "initial"; git tag initial
git tag v000-base
}
Expand All @@ -35,7 +36,6 @@ function make_change() {
# Mark a branch tip as PR tip.
# $1 = PR number.
function tag_pr() {
mkdir -p .git/refs/pull/origin
git log --pretty=tformat:%H > .git/refs/pull/origin/$1
}

Expand Down
6 changes: 3 additions & 3 deletions scripts/release-notes/test1.notes.ref.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,16 @@ Docs team: Please add these manually.

### Contributors

This release includes 2 merged PRs by 1 author.
This release includes 2 merged PRs and 1 standalone commit by 1 author.
We would like to thank the following contributors from the CockroachDB community:

- test1

### PRs merged by contributors

- test1:
- 2018-04-22 [#unknown][#unknown] [e3a1f2c94][e3a1f2c94] (+ 0 - 0 ~ 0/ 0) master update
- 2018-04-22 [#100 ][#100 ] [884025a61][884025a61] (+ 0 - 0 ~ 0/ 0) PR title alternate format
- 2018-04-22 [#unknown][#unknown] [e3a1f2c94][e3a1f2c94] (+ 0 - 0 ~ 0/ 0) master update [NO RELEASE NOTE]
- 2018-04-22 [#100 ][#100 ] [884025a61][884025a61] (+ 0 - 0 ~ 0/ 0) PR title alternate format [NO RELEASE NOTE]
- 2018-04-22 [#1 ][#1 ] [c95ebe826][c95ebe826] (+ 0 - 0 ~ 0/ 0) PR title


Expand Down
2 changes: 2 additions & 0 deletions scripts/release-notes/test10.graph.ref.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
* aebaacf8730eba9e9530f92b12179a450d532ec7 master update
* 89f7cef5fdf8310a9d5a97789c6152a2b9da5921 initial
24 changes: 24 additions & 0 deletions scripts/release-notes/test10.notes.ref.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
### Bug fixes

- Some fix. [#unknown][#unknown] [aebaacf87][aebaacf87]

### Doc updates

Docs team: Please add these manually.

### Contributors

This release includes 1 standalone commit by 1 author.
We would like to thank the following contributors from the CockroachDB community:

- test10

### PRs merged by contributors

- test10:
- 2018-04-22 [#unknown][#unknown] [aebaacf87][aebaacf87] (+ 0 - 0 ~ 0/ 0) master update


[#unknown]: https://github.com/cockroachdb/cockroach/pull/unknown
[aebaacf87]: https://github.com/cockroachdb/cockroach/commit/aebaacf87

26 changes: 26 additions & 0 deletions scripts/release-notes/test10.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/bin/sh
set -eux

. common.sh

t=test10
relnotescript=${1:?}
rewrite=${2:-}

test_init

(
cd $t
init_repo
git checkout -b feature
make_change "feature A"
tag_pr 1
git checkout master

make_change "master update
Release note (bug fix): some fix.
"
)

test_end
6 changes: 3 additions & 3 deletions scripts/release-notes/test2.notes.ref.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,16 @@ Docs team: Please add these manually.

### Contributors

This release includes 2 merged PRs by 1 author.
This release includes 2 merged PRs and 1 standalone commit by 1 author.
We would like to thank the following contributors from the CockroachDB community:

- test2

### PRs merged by contributors

- test2:
- 2018-04-22 [#unknown][#unknown] [f872999e8][f872999e8] (+ 0 - 0 ~ 0/ 0) master update
- 2018-04-22 [#100 ][#100 ] [e9b08c236][e9b08c236] (+ 0 - 0 ~ 0/ 0) PR title alternate format
- 2018-04-22 [#unknown][#unknown] [f872999e8][f872999e8] (+ 0 - 0 ~ 0/ 0) master update [NO RELEASE NOTE]
- 2018-04-22 [#100 ][#100 ] [e9b08c236][e9b08c236] (+ 0 - 0 ~ 0/ 0) PR title alternate format [NO RELEASE NOTE]
- 2018-04-22 [#1 ][#1 ] [7358b462a][7358b462a] (+ 0 - 0 ~ 0/ 0) PR title (2 commits)


Expand Down
6 changes: 3 additions & 3 deletions scripts/release-notes/test3.notes.ref.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,16 @@ Docs team: Please add these manually.

### Contributors

This release includes 2 merged PRs by 1 author.
This release includes 2 merged PRs and 1 standalone commit by 1 author.
We would like to thank the following contributors from the CockroachDB community:

- test3

### PRs merged by contributors

- test3:
- 2018-04-22 [#unknown][#unknown] [4f4329fdc][4f4329fdc] (+ 0 - 0 ~ 0/ 0) master update
- 2018-04-22 [#100 ][#100 ] [b719cfe9e][b719cfe9e] (+ 0 - 0 ~ 0/ 0) PR title alternate format
- 2018-04-22 [#unknown][#unknown] [4f4329fdc][4f4329fdc] (+ 0 - 0 ~ 0/ 0) master update [NO RELEASE NOTE]
- 2018-04-22 [#100 ][#100 ] [b719cfe9e][b719cfe9e] (+ 0 - 0 ~ 0/ 0) PR title alternate format [NO RELEASE NOTE]
- 2018-04-22 [#1 ][#1 ] [ef634455e][ef634455e] (+ 0 - 0 ~ 0/ 0) PR title (4 commits)


Expand Down
2 changes: 1 addition & 1 deletion scripts/release-notes/test4.notes.ref.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ We would like to thank the following contributors from the CockroachDB community
- 2018-04-22 [#1 ][#1 ] [32204525a][32204525a] (+ 0 - 0 ~ 0/ 0) PR title (5 commits)

- test4:
- 2018-04-22 [#100 ][#100 ] [1525c88bd][1525c88bd] (+ 0 - 0 ~ 0/ 0) PR title alternate format
- 2018-04-22 [#100 ][#100 ] [1525c88bd][1525c88bd] (+ 0 - 0 ~ 0/ 0) PR title alternate format [NO RELEASE NOTE]


[#1]: https://github.com/cockroachdb/cockroach/pull/1
Expand Down
6 changes: 3 additions & 3 deletions scripts/release-notes/test5.notes.ref.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ We would like to thank the following contributors from the CockroachDB community
### PRs merged by contributors

- test5:
- 2018-04-22 [#200 ][#200 ] [d3ba7bcec][d3ba7bcec] (+ 0 - 0 ~ 0/ 0) PR title in need of release note alternate format
- 2018-04-22 [#2 ][#2 ] [931c78112][931c78112] (+ 0 - 0 ~ 0/ 0) PR title in need of release note
- 2018-04-22 [#100 ][#100 ] [cfb4c716b][cfb4c716b] (+ 0 - 0 ~ 0/ 0) PR title alternate format
- 2018-04-22 [#200 ][#200 ] [d3ba7bcec][d3ba7bcec] (+ 0 - 0 ~ 0/ 0) PR title in need of release note alternate format [NO RELEASE NOTE]
- 2018-04-22 [#2 ][#2 ] [931c78112][931c78112] (+ 0 - 0 ~ 0/ 0) PR title in need of release note [NO RELEASE NOTE]
- 2018-04-22 [#100 ][#100 ] [cfb4c716b][cfb4c716b] (+ 0 - 0 ~ 0/ 0) PR title alternate format [NO RELEASE NOTE]
- 2018-04-22 [#1 ][#1 ] [b8a9a7f70][b8a9a7f70] (+ 0 - 0 ~ 0/ 0) PR title (2 commits)


Expand Down
8 changes: 4 additions & 4 deletions scripts/release-notes/test6.notes.ref.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ We would like to thank the following contributors from the CockroachDB community
### PRs merged by contributors

- test6:
- 2018-04-22 [#200 ][#200 ] [5105ca93f][5105ca93f] (+ 0 - 0 ~ 0/ 0) PR title 2 alternate format
- 2018-04-22 [#2 ][#2 ] [38b0488f9][38b0488f9] (+ 0 - 0 ~ 0/ 0) PR title 2 (2 commits)
- 2018-04-22 [#100 ][#100 ] [4279dfba7][4279dfba7] (+ 0 - 0 ~ 0/ 0) PR title 1 alternate format
- 2018-04-22 [#1 ][#1 ] [2ae4772fb][2ae4772fb] (+ 0 - 0 ~ 0/ 0) PR title 1
- 2018-04-22 [#200 ][#200 ] [5105ca93f][5105ca93f] (+ 0 - 0 ~ 0/ 0) PR title 2 alternate format [NO RELEASE NOTE]
- 2018-04-22 [#2 ][#2 ] [38b0488f9][38b0488f9] (+ 0 - 0 ~ 0/ 0) PR title 2 (2 commits) [NO RELEASE NOTE]
- 2018-04-22 [#100 ][#100 ] [4279dfba7][4279dfba7] (+ 0 - 0 ~ 0/ 0) PR title 1 alternate format [NO RELEASE NOTE]
- 2018-04-22 [#1 ][#1 ] [2ae4772fb][2ae4772fb] (+ 0 - 0 ~ 0/ 0) PR title 1 [NO RELEASE NOTE]


[#1]: https://github.com/cockroachdb/cockroach/pull/1
Expand Down
2 changes: 1 addition & 1 deletion scripts/release-notes/test7.notes.ref.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ We would like to thank the following contributors from the CockroachDB community

- test7:
- 2018-04-22 [#200 ][#200 ] [28245dacd][28245dacd] (+ 0 - 0 ~ 0/ 0) PR title 2 alternate format (2 commits)
- 2018-04-22 [#100 ][#100 ] [ba15054b5][ba15054b5] (+ 0 - 0 ~ 0/ 0) PR title 1 alternate format
- 2018-04-22 [#100 ][#100 ] [ba15054b5][ba15054b5] (+ 0 - 0 ~ 0/ 0) PR title 1 alternate format [NO RELEASE NOTE]
- 2018-04-22 [#1 ][#1 ] [191b497b9][191b497b9] (+ 0 - 0 ~ 0/ 0) PR title 1 (2 commits)


Expand Down
12 changes: 6 additions & 6 deletions scripts/release-notes/test8.notes.ref.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Docs team: Please add these manually.

### Contributors

This release includes 4 merged PRs by 2 authors.
This release includes 4 merged PRs and 1 standalone commit by 2 authors.
We would like to thank the following contributors from the CockroachDB community:

- Foo Foo (first-time contributor)
Expand All @@ -21,13 +21,13 @@ We would like to thank the following contributors from the CockroachDB community
### PRs merged by contributors

- Foo Foo, test8:
- 2018-04-22 [#2 ][#2 ] [20f736f8b][20f736f8b] (+ 0 - 0 ~ 0/ 0) PR 2 title
- 2018-04-22 [#1 ][#1 ] [931a97757][931a97757] (+ 0 - 0 ~ 0/ 0) PR 1 title
- 2018-04-22 [#2 ][#2 ] [20f736f8b][20f736f8b] (+ 0 - 0 ~ 0/ 0) PR 2 title [NO RELEASE NOTE]
- 2018-04-22 [#1 ][#1 ] [931a97757][931a97757] (+ 0 - 0 ~ 0/ 0) PR 1 title [NO RELEASE NOTE]

- test8:
- 2018-04-22 [#unknown][#unknown] [a1dec5651][a1dec5651] (+ 1 - 0 ~ 1/ 1) update AUTHORS
- 2018-04-22 [#200 ][#200 ] [801acad03][801acad03] (+ 0 - 0 ~ 0/ 0) PR 2 title alternate format
- 2018-04-22 [#100 ][#100 ] [ac02f9cf6][ac02f9cf6] (+ 0 - 0 ~ 0/ 0) PR 1 title alternate format
- 2018-04-22 [#unknown][#unknown] [a1dec5651][a1dec5651] (+ 1 - 0 ~ 1/ 1) update AUTHORS [NO RELEASE NOTE]
- 2018-04-22 [#200 ][#200 ] [801acad03][801acad03] (+ 0 - 0 ~ 0/ 0) PR 2 title alternate format [NO RELEASE NOTE]
- 2018-04-22 [#100 ][#100 ] [ac02f9cf6][ac02f9cf6] (+ 0 - 0 ~ 0/ 0) PR 1 title alternate format [NO RELEASE NOTE]


[#1]: https://github.com/cockroachdb/cockroach/pull/1
Expand Down
6 changes: 3 additions & 3 deletions scripts/release-notes/test9.notes.ref.txt
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ We would like to thank the following contributors from the CockroachDB community
### PRs merged by contributors

- test9:
- 2018-04-22 [#200 ][#200 ] [3905a9e95][3905a9e95] (+ 0 - 0 ~ 0/ 0) PR 2 title alternate format
- 2018-04-22 [#2 ][#2 ] [b6d311cae][b6d311cae] (+ 0 - 0 ~ 0/ 0) PR 2 title (4 commits)
- 2018-04-22 [#100 ][#100 ] [6286c37ea][6286c37ea] (+ 0 - 0 ~ 0/ 0) PR 1 title alternate format
- 2018-04-22 [#200 ][#200 ] [3905a9e95][3905a9e95] (+ 0 - 0 ~ 0/ 0) PR 2 title alternate format [NO RELEASE NOTE]
- 2018-04-22 [#2 ][#2 ] [b6d311cae][b6d311cae] (+ 0 - 0 ~ 0/ 0) PR 2 title (4 commits) [NO RELEASE NOTE]
- 2018-04-22 [#100 ][#100 ] [6286c37ea][6286c37ea] (+ 0 - 0 ~ 0/ 0) PR 1 title alternate format [NO RELEASE NOTE]
- 2018-04-22 [#1 ][#1 ] [0b2581ed1][0b2581ed1] (+ 0 - 0 ~ 0/ 0) PR 1 title (2 commits)


Expand Down

0 comments on commit 3d6f729

Please sign in to comment.