Commit Graph

20 Commits

Author SHA1 Message Date
Konsta Hölttä
e3240db272 scripts: rfr: fix url regexes for good
Make the .nvidia.com part more correct by escaping the all-matching
dots, and optional for also the more modern formats because some tools
still produce them. Add a dot in the project part (e.g. linux-5.9).

Change-Id: Iad54b3160a9c422889a61d5f326c3d637b3f4b80
Signed-off-by: Konsta Hölttä <kholtta@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvgpu/+/2361787
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
Reviewed-by: Alex Waterman <alexw@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
GVS: Gerrit_Virtual_Submit
2020-12-15 14:13:28 -06:00
Konsta Hölttä
f9e9e41c7b scripts: rfr: convert to python 3
Python 2 is no longer maintained. Use python 3 to be up to date and to
make it easier to work with utf-8 text.

Change-Id: I341f558730caaa9106e8eef4304d67af747c7373
Signed-off-by: Konsta Hölttä <kholtta@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvgpu/+/2318760
Reviewed-by: automaticguardword <automaticguardword@nvidia.com>
Reviewed-by: Alex Waterman <alexw@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
GVS: Gerrit_Virtual_Submit
2020-12-15 14:13:28 -06:00
Konsta Hölttä
0cd5502935 scripts: rfr: fix urls with digits
With just (\d+), the very first regex would find a number within a
longer string, which for the following example would be wrongly 3, not
2318270. Make it match just a number and nothing else. Interestingly,
plain number search would work for most gerrit urls, but let's be
specific to avoid accidents.

example: https://git-master.nvidia.com/r/c/3rdparty/qnx/src/+/2318270

Also make the list more concise by joining almost identical pairs that
differ by just one character: use "?" to make the character optional.

Change-Id: Ia1b2ee4270c599ec7bcc2c4375c8a8f498043b27
Signed-off-by: Konsta Hölttä <kholtta@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvgpu/+/2318496
Reviewed-by: automaticguardword <automaticguardword@nvidia.com>
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: Thomas Fleury <tfleury@nvidia.com>
Reviewed-by: Alex Waterman <alexw@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
GVS: Gerrit_Virtual_Submit
2020-12-15 14:13:28 -06:00
Thomas Fleury
198b7638ec scripts: rfr: add regex to match patch number
Add regex rule to match patch number, e.g
./rfr 2279114
./rfr https://git-master.nvidia.com/r/c/linux-nvgpu/+/2279114

Would be equivalent.

Change-Id: I3ffa5f233951d5e4d404517362e984c7a04b9849
Signed-off-by: Thomas Fleury <tfleury@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvgpu/+/2283726
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: Alex Waterman <alexw@nvidia.com>
Reviewed-by: Vinod Gopalakrishnakurup <vinodg@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
GVS: Gerrit_Virtual_Submit
2020-12-15 14:10:29 -06:00
Thomas Fleury
b78bb66534 scripts: rfr: update gerrit URL format
Update rfr script to handle new gerrit URL format.

Change-Id: Ic08feaaff7e9ab756425652ffdd1e79862856f0e
Signed-off-by: Thomas Fleury <tfleury@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvgpu/+/2279114
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: Alex Waterman <alexw@nvidia.com>
Reviewed-by: Seshendra Gadagottu <sgadagottu@nvidia.com>
Tested-by: Seshendra Gadagottu <sgadagottu@nvidia.com>
GVS: Gerrit_Virtual_Submit
Reviewed-by: Vinod Gopalakrishnakurup <vinodg@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
2020-12-15 14:10:29 -06:00
Alex Waterman
33b31bea1a scripts: rfr: Fix merge commit bug
The file +/- computation in the function that generates the email
message text expects there to be files present in the git/gerrit
commit object. But for merge commits there are no files present
in the merge commit itself. A max() function ended up getting an
empty list as an argument and then caused a crash.

Fix this by checking to make sure there's actually files present
in this list before passing it on to max(). If there are no files
then just continue.

Change-Id: Icd74234676ff3be6edb7fe65913970fd7a0aaff1
Signed-off-by: Alex Waterman <alexw@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/2226035
Reviewed-by: Thomas Fleury <tfleury@nvidia.com>
GVS: Gerrit_Virtual_Submit
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
2020-12-15 14:10:29 -06:00
Konsta Holtta
b22202d084 scripts: rfr: bring back empty line between commits
A change to add the file statistics accidentally lost a separating blank
line between the formatted commit sections. Add it back.

Change-Id: I8b6d60aa2460775593ecb4167f2fbe46c0639765
Signed-off-by: Konsta Holtta <kholtta@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/2027280
GVS: Gerrit_Virtual_Submit
Reviewed-by: Philip Elcan <pelcan@nvidia.com>
Reviewed-by: Alex Waterman <alexw@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
2019-02-25 11:05:35 -08:00
Konsta Holtta
05e3be8177 gpu: nvgpu: rfr: print file statistics
Add a listing of changed files after the commit messages similar to how
git show --stat would put it. This makes it trivial to see where the
changes happened if the commit description doesn't state it.

Example from this patch:

  scripts/rfr | 23  (+20  -3  )

The numbers are padded to a width of three so they line up nicely.

Change-Id: Ie62ea6c7d1d3b21446c7447f362d148be3032076
Signed-off-by: Konsta Holtta <kholtta@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/2020196
GVS: Gerrit_Virtual_Submit
Reviewed-by: Philip Elcan <pelcan@nvidia.com>
Reviewed-by: Vijayakumar Subbu <vsubbu@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
2019-02-18 02:06:23 -08:00
Alex Waterman
dd4c60aeb5 gpu: nvgpu: rfr: Add address book
Add an address book that lets devs use short hand for specifying
--to and --cc targets. For example, if a dev wants to CC the MISRA
list this can be used:

  $ ./scripts/rfr -e --cc misra ...

The address book also lets devs add their own names/email addresses
since this makes it convenient to CC individual people. For example:

  $ ./scripts/rfr -e --cc alex ...

Several new arguments were added to support the address book. There
are arguments to list/search the address book, ignore the address
book, and to prevent nvgpu-core from being added to the to address
by default. For more details see the help page.

To use an address book there's several options: place one at

  ~/.rfr-addrbook

Export an RFR_ADDRBOOK environment variable pointing to the address
book, or specify one with the `-a' option. The address book contents
is simple. All empty lines and lines beginning with '#' are ignored.
The remaining lines are split by '|' and the first half of the line
is considered a nickname and the latter half the address. An example:

  alex | alex waterman <alexw@nvidia.com>

This will let you specify `--to alex' instead of the full email
address. This is especially useful for mailing lists.

Lastly there is more documentation located at:

  https://confluence.nvidia.com/display/TGS/NVGPU+Request+For+Review

[Bump version to 1.1.0]

Change-Id: Iac7ec05ae28d7e888d2bf36bd23574ec49eb04dc
Signed-off-by: Alex Waterman <alexw@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/1983695
Reviewed-by: Rohit Khanna <rokhanna@nvidia.com>
2019-01-16 15:38:18 -08:00
Alex Waterman
67138e0376 gpu: nvgpu: rfr: Add support for CCs
Add support for CCs instead of only direct To addresses. This
lets us have more fine grained control over the to/cc addresses.

[Bump minor revision to 1.0.3]

Change-Id: Ie2864ddde02a71a4502bf2b3d0d80064810da0ef
Signed-off-by: Alex Waterman <alexw@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/1983663
Reviewed-by: Rohit Khanna <rokhanna@nvidia.com>
2019-01-16 15:38:14 -08:00
Alex Waterman
e2aa359774 gpu: nvgpu: rfr: Notify user of email destination
When sending emails it can be nice to see who you are sending an
email to if you specify multiple '--to' options.

Also update the get_user_message() function to remove comment lines
starting with '#'. This lets the script place information useful
to a developer in the message that won't ultimately make it to the
final email.

[Bump minor revision to 1.0.2]

Change-Id: I3657a787d8e9a8c19de727e050a0b9a18a6d43e0
Signed-off-by: Alex Waterman <alexw@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/1983642
Reviewed-by: Rohit Khanna <rokhanna@nvidia.com>
2019-01-16 15:38:11 -08:00
Alex Waterman
bf51b0cdf7 gpu: nvgpu: Update license for some scripts
Update (or add) the MIT license for several scripts in the nvgpu
code.

Change-Id: I3724c3cf22358773cc7dcaa8a8bb8acba439d216
Signed-off-by: Alex Waterman <alexw@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/1946911
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: Nitin Kumbhar <nkumbhar@nvidia.com>
Reviewed-by: Terje Bergstrom <tbergstrom@nvidia.com>
GVS: Gerrit_Virtual_Submit
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
2018-11-12 15:46:49 -08:00
Alex Waterman
138e70b0d4 scripts: rfr: Add file support
Add support for reading a file full of commit IDs/URLs. This
makes generating an RFR from a long list of commits easier in
some cases.

Change-Id: Id71173853e29d951048e8c3394ffce5d8b1eeb52
Signed-off-by: Alex Waterman <alexw@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/1576523
Reviewed-by: Konsta Holtta <kholtta@nvidia.com>
Reviewed-by: svc-misra-checker <svc-misra-checker@nvidia.com>
Reviewed-by: svccoveritychecker <svccoveritychecker@nvidia.com>
GVS: Gerrit_Virtual_Submit
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
2018-08-22 10:23:35 -07:00
Konsta Holtta
bf8a1e0019 scripts: rfr: support multiple recipients
Add an argument (-t, --to) to specify additional recipients for the
review email. Sometimes it's useful to highlight some people explicitly
or in addition to the usual nvgpu core list.

In the future, we might consider adding some heuristics for less typing
(such as adding @nvidia.com automatically). For now the addresses have
to be complete.

Change-Id: I0e4ce5974a7a2f3db6eacc7128b825d20d6fd57c
Signed-off-by: Konsta Holtta <kholtta@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/1768066
GVS: Gerrit_Virtual_Submit
Reviewed-by: Alex Waterman <alexw@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
2018-08-21 10:03:01 -07:00
Alex Waterman
641c208948 scripts: rfr: Direct email support
Add support for `rfr' to send emails directly to the nvgpu-core mailing
list. Copying the email contents and then manually updating it is
annoying. This streamlines that process greatly!

Since most people always write something extra past what the `rfr'
script generates you can edit the message before it sends. If you don't
specify a message explicitly with '--msg' then an editor based on your
setting of $EDITOR is opened up with the contents of the email. What
you edit into there will be sent verbatim. If for some reason you want
nothing to be added there's the '--no-msg' option.

Change-Id: Icb0ccba936357cf5e3a93001a5c22aeacf906e11
Signed-off-by: Alex Waterman <alexw@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/1595544
GVS: Gerrit_Virtual_Submit
Reviewed-by: Konsta Holtta <kholtta@nvidia.com>
Tested-by: Konsta Holtta <kholtta@nvidia.com>
Reviewed-by: Terje Bergstrom <tbergstrom@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
2018-06-28 11:13:24 -07:00
Richard Zhao
a55e3e361d scripts: rfr: support https://git-master.nvidia.com/r/#/c/(\d+)
https://git-master.nvidia.com/r/#/c/(\d+) is acceptable format for
gerrit website and it won't auto-correct by adding '/' at endof the url.

Jira EVLR-2364

Change-Id: I1a33578058d23fbb3eaf76d260a1a659c628fdc3
Signed-off-by: Richard Zhao <rizhao@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/1646315
Reviewed-by: Alex Waterman <alexw@nvidia.com>
Reviewed-by: Seshendra Gadagottu <sgadagottu@nvidia.com>
GVS: Gerrit_Virtual_Submit
Reviewed-by: Terje Bergstrom <tbergstrom@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
2018-01-31 02:41:07 -08:00
Konsta Holtta
7e493175de scripts: rfr: query gerrit for git sha1
The gerrit search supports git sha1 revisions, so use that directly when
given a git commit.

This changes the behaviour such that the change-id found from the commit
message is not used implicitly, which removes ambiguity.

Change-Id: Ifac1002421886dc73234b530d937395aae5addee
Signed-off-by: Konsta Holtta <kholtta@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/1585437
GVS: Gerrit_Virtual_Submit
Reviewed-by: Alex Waterman <alexw@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
2017-11-01 00:05:19 -07:00
Konsta Holtta
b5b9e71bd5 scripts: rfr: explicitly use gerrit cl if needed
Fetch the full patch information from gerrit as soon as possible, so
that the gerrit cl (i.e., git-master url) is used if given, because it
has more information than the change-id (which may exist in multiple
branches).

Querying based on change-id or git commit-id are left as-is.

Change-Id: I58dfa9da7354d607ca7e38f91e4a5f2c92c8454f
Signed-off-by: Konsta Holtta <kholtta@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/1585436
Reviewed-by: Alex Waterman <alexw@nvidia.com>
GVS: Gerrit_Virtual_Submit
Reviewed-by: Vijayakumar Subbu <vsubbu@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
2017-11-01 00:05:14 -07:00
Alex Waterman
980bf96bf2 scripts: rfr: Remove duplicate subjects
The commit subject is printed implicitly in the commit message
so remove the subject from the header generated by `rfr'.

Also delete a debug line that got left over accidentally.

Change-Id: Ia7fe704182d87504c5794ad4661d8dd2f14bc51f
Signed-off-by: Alex Waterman <alexw@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/1558431
Reviewed-by: Konsta Holtta <kholtta@nvidia.com>
Reviewed-by: Terje Bergstrom <tbergstrom@nvidia.com>
2017-09-13 16:08:31 -07:00
Alex Waterman
65f18d74ee scripts: Add an 'rfr' program
Add an RFR program to generate RFR emails. Since there are many emails
sent with either no information or lacking information this script
will help make RFR emails more useful to developers interested in
conducting reviews.

The help is as follows:

  $ ./rfr --help
  usage: rfr [-h] [-V] [-m MSG] Commit-IDs [Commit-IDs ...]

  RFR formatting tool

  positional arguments:
    Commit-IDs         Git or gerrit commits to describe. Can be either a git or
                       gerrit commit ID. If the ID starts with a 'I' then it
                       will be treated as a gerrit ID. If the commit ID looks
                       like a gerrit URL then it is treated as a gerrit URL.
                       Otherwise it's treated as a git commit ID.

  optional arguments:
    -h, --help         show this help message and exit
    -V, --version      print the program version
    -m MSG, --msg MSG  Custom message to add to the RFR email

  This program will format commit messages into something that can be sent to
  the nvgpu mailing list for review

The Commit IDs can be a git commit ID, gerrit change ID, or a gerrit URL. For
example:

  # Git commit IDs (abbreviated are ok)
  $ ./rfr 89e2470807
  $ ./rfr 89e2470807571ef6dc545ece8f5f7e43e27b0c12

  # Gerrit Change-Id (also can be abbreviated)
  $ ./rfr I0524ae1982fbce9eb4da976e72102e08e2dcd017
  $ ./rfr I0524ae198

  # And lastly, several different URL formats:
  https://git-master.nvidia.com/r/#/c/1553782/2
  https://git-master.nvidia.com/r/#/c/1553782/
  https://git-master.nvidia.com/r/1553782
  https://git-master/r/1553782

The only currently known bug is that if yo have multiple versions of a
commit that share the same gerrit Change-ID then this script will only
take the first one. For example if there's a bunch of cherry-picks then
which commit is taken is undefined.

It seems like generally the order that gerrit returns changes puts open
changes first, but this is not tested nor should this be relied upon. At
some point supporting some mechanism to filter will be necessary.

Change-Id: I0524ae1982fbce9eb4da976e72102e08e2dcd017
Signed-off-by: Alex Waterman <alexw@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/1552173
Reviewed-by: Terje Bergstrom <tbergstrom@nvidia.com>
2017-09-11 15:50:42 -07:00