зеркало из https://github.com/microsoft/azure-cli.git
{Misc} Update history generation, PR template and doc (#12853)
This commit is contained in:
Родитель
ec56c6681b
Коммит
806e4318d0
|
@ -1,14 +1,14 @@
|
|||
**Description of PR (Mandatory)**
|
||||
(Why this PR? What is changed? What is the effect? etc. A high-quality description can accelerate the review process)
|
||||
**Description<!--Mandatory-->**
|
||||
<!--Why this PR? What is changed? What is the effect? etc. A high-quality description can accelerate the review process.-->
|
||||
|
||||
**Testing Guide**
|
||||
(Example commands with explanations)
|
||||
<!--Example commands with explanations.-->
|
||||
|
||||
**History Notes:**
|
||||
(Fill in the following template if multiple notes are needed, otherwise PR title will be used for history note.)
|
||||
**History Notes**
|
||||
<!--If your PR is not customer-facing, use {Component Name} in the PR title. Otherwise, use [Component Name] to allow our pipeline to add the title as a history note. If you need multiple history notes or would like to overwrite the note from the PR title, please fill in the following templates.-->
|
||||
|
||||
[Component Name 1] (BREAKING CHANGE:) (az command:) make some customer-facing change.
|
||||
[Component Name 2] (BREAKING CHANGE:) (az command:) make some customer-facing change.
|
||||
[Component Name 1] BREAKING CHANGE: az command a: Make some customer-facing breaking change.
|
||||
[Component Name 2] az command b: Add some customer-facing feature.
|
||||
|
||||
---
|
||||
|
||||
|
|
|
@ -23,6 +23,10 @@ jobs:
|
|||
- bash: |
|
||||
echo "Check Title of Pull Request: #$(System.PullRequest.PullRequestNumber)"
|
||||
title=$(curl https://api.github.com/repos/Azure/azure-cli/pulls/$(System.PullRequest.PullRequestNumber) | jq -r '.title')
|
||||
if [ "$(System.PullRequest.TargetBranch)" != "release" ] && echo $title | grep -iqF hotfix; then
|
||||
echo "Hotfix PR should target release branch."
|
||||
exit 1
|
||||
fi
|
||||
[[ $title =~ ^(\[.*\]|\{.*\}).* ]] && exit 0
|
||||
echo "Pull Request title should follow https://aka.ms/submitAzPR"
|
||||
exit 1
|
||||
|
|
|
@ -202,13 +202,13 @@ Submitting Pull Requests
|
|||
### Format PR Title
|
||||
|
||||
History notes are auto-generated based on PR titles and descriptions starting from [S165](https://github.com/Azure/azure-cli/milestone/82). Starting from 01/30/2020, we require all the PR titles to follow the below format:
|
||||
1. [**Mandatory**] Each PR title must start with `[Component Name]` or `{Component Name}`.
|
||||
1. [**Mandatory**] Each PR title **MUST** start with `[Component Name]` or `{Component Name}`.
|
||||
* `Component Name` shall be replaced by the real ones such as `Storage`, `Compute`. It could be the name of a command module, but in title case with necessary spaces for better readability, such as `API Management`, `Managed Service`. Other possible component names include but are not limited to: `Packaging`, `Misc.`, `Aladdin`.
|
||||
* `[]` means this change is customer-facing and the message will be put into `HISTORY.rst`. `{}` means this change is not customer-facing and the message will **NOT** be included in `HISTORY.rst`.
|
||||
* If the component name is `Core`, the message will be written in `src/azure-cli-core/HISTORY.rst`. Otherwise, the message will be written in `src/azure-cli/HISTORY.rst`.
|
||||
2. [**Mandatory**] If it's a breaking change, the second part should be `BREAKING CHANGE` followed by a colon. In the case of hotfix, put `Hotfix` in this part. If it's related to fixing an issue, put `Fix #number` in this part. For other cases, this part could be empty.
|
||||
3. [**Recommendation**] If the change can be mapped into a command, then the next part could be the command name, followed by a colon.
|
||||
4. [**Recommendation**] Use the right verb with present-tense in original form to descibe what is done:
|
||||
3. [**Recommendation**] If the change can be mapped into a command, then the next part could be the command name starting with `az`, followed by a colon.
|
||||
4. [**Recommendation**] Use the right verb with **present-tense** in **base form** and **capitalized first letter** to descibe what is done:
|
||||
* **Add** for new features.
|
||||
* **Change** for changes in existing functionality.
|
||||
* **Deprecate** for once-stable features removed in upcoming releases.
|
||||
|
@ -217,7 +217,7 @@ History notes are auto-generated based on PR titles and descriptions starting fr
|
|||
|
||||
Examples of customer-facing change PR title:
|
||||
|
||||
>[Storage] BREAKING CHANGE: az storage remove: remove --auth-mode argument
|
||||
>[Storage] BREAKING CHANGE: az storage remove: Remove --auth-mode argument
|
||||
>[ARM] Fix #10246: az resource tag crashes when the parameter --ids passed in is resource group ID
|
||||
|
||||
An example of non-customer-facing change PR title:
|
||||
|
@ -226,13 +226,16 @@ An example of non-customer-facing change PR title:
|
|||
|
||||
### Format PR Description
|
||||
|
||||
If you would like to write multiple history notes for one PR, please write the notes under `History Notes` section in the PR description, following the same format described above. The PR template already contains the history note template, just change it if needed. In this case, the PR title should be a summary of all the changes in this PR and will not be put into `HISTORY.rst`. You can delete the `History Notes` section if not needed.
|
||||
Please follow the instruction in the PR template to provide a description of the PR and the testing guide if possible.
|
||||
|
||||
Other than that, you can put any reasonable information in the description above the `History Notes` part.
|
||||
If you would like to write multiple history notes for one PR or overwrite the message in the PR title as a history note, please write the notes under `History Notes` section in the PR description, following the same format described above. The PR template already contains the history note template, just change it if needed. In this case, the PR title could be a summary of all the changes in this PR and will not be put into `HISTORY.rst` in our pipeline. The PR title still needs to start with `[Component Name]`. You can delete the `History Notes` section if not needed.
|
||||
|
||||
### Submit Hotfix
|
||||
In the case of hotfix, you should create a hotfix branch based on release branch and submit a PR to merge hotfix into release. In this PR, the second part of the PR title should be `Hotfix`. If you have customer-facing changes, you need to modify `HISTORY.rst` to add history notes. The auto generated history notes for the next release will ignore the PR that contains `Hotfix`. You also need to submit a PR to merge the release branch back into dev branch before next release. Do **NOT** squash and merge this PR. After the PR gets approved by code owners, you should fast forward dev to release on your local machine and then push dev to upstream repository.
|
||||
### Hotfix PR
|
||||
Step 1: Create a hotfix branch based on release branch, then submit a PR to merge hotfix into release.
|
||||
In this PR, the second part of the PR title should be `Hotfix`. If you have customer-facing changes, you need to manually modify `HISTORY.rst` to add history notes. The auto generated history notes for the next regular release will ignore the PR that contains `Hotfix`.
|
||||
Step 2: Submit a PR to merge the release branch back into dev branch after the hotfix release.
|
||||
Do **NOT** squash and merge this PR. After the PR gets approved by code owners, you should fast forward dev to release on your local machine and then push dev to upstream repository.
|
||||
|
||||
An example title of hotfix change PR:
|
||||
|
||||
>{Packaging} Hotfix: fix dependency error
|
||||
>{Packaging} Hotfix: Fix dependency error
|
||||
|
|
|
@ -100,8 +100,9 @@ def construct_core_history(component: str):
|
|||
|
||||
|
||||
def get_commits():
|
||||
last_release = 'azure-cli-{}'.format(os.getenv('PRE_VERSION')) if os.getenv('PRE_VERSION') else 'upstream/release'
|
||||
out = subprocess.Popen([
|
||||
'git', 'log', 'upstream/release...upstream/dev',
|
||||
'git', 'log', '{}..upstream/dev'.format(last_release),
|
||||
'--pretty=format:"%H %s"'
|
||||
],
|
||||
stdout=subprocess.PIPE,
|
||||
|
@ -112,8 +113,7 @@ def get_commits():
|
|||
words = line.strip('"').split(None, 1)
|
||||
sha = words[0]
|
||||
subject = words[1]
|
||||
if not subject.startswith('{'):
|
||||
dev_commits.append({'sha': sha, 'subject': subject})
|
||||
dev_commits.append({'sha': sha, 'subject': subject})
|
||||
dev_commits.reverse()
|
||||
return dev_commits
|
||||
|
||||
|
@ -144,7 +144,7 @@ def process_pr(pr):
|
|||
else:
|
||||
body = search_result.group(1)
|
||||
lines.extend(body.splitlines())
|
||||
process_lines(lines)
|
||||
process_lines(lines, pr['number'])
|
||||
|
||||
|
||||
def process_commit(commit):
|
||||
|
@ -152,43 +152,52 @@ def process_commit(commit):
|
|||
process_lines(lines)
|
||||
|
||||
|
||||
def process_lines(lines: [str]):
|
||||
def process_lines(lines: [str], pr_num: str = None):
|
||||
# do not put note of hotfix here since it's for last release
|
||||
if re.search('hotfix', lines[0], re.IGNORECASE):
|
||||
return
|
||||
note_in_desc = False
|
||||
for desc in lines[1:]:
|
||||
component, note = parse_message(desc)
|
||||
component, note = parse_message(desc, pr_num)
|
||||
if component is not None:
|
||||
note_in_desc = True
|
||||
history_notes.setdefault(component, []).append(note)
|
||||
# if description has no history notes, parse PR title/commit message
|
||||
# otherwise should skip PR title/commit message
|
||||
if not note_in_desc:
|
||||
component, note = parse_message(lines[0])
|
||||
component, note = parse_message(lines[0], pr_num)
|
||||
if component is not None:
|
||||
history_notes.setdefault(component, []).append(note)
|
||||
|
||||
|
||||
def parse_message(message: str) -> (str, str):
|
||||
def parse_message(message: str, pr_num: str = None) -> (str, str):
|
||||
# do not include template
|
||||
if message.startswith('[Component Name'):
|
||||
return None, None
|
||||
m = re.search(r'^\[(.+)\](.+)$', message)
|
||||
m = re.search(r'^\[(.+?)\](.+)$', message)
|
||||
if m is not None:
|
||||
component = m.group(1)
|
||||
note = m.group(2).strip()
|
||||
#remove appended PR number in commit message
|
||||
note = re.sub(r' \(#[0-9]+\)$', '', note)
|
||||
if not pr_number_appended(note) and pr_num:
|
||||
note = '{} (#{})'.format(note, pr_num)
|
||||
note = re.sub('BREAKING CHANGE:',
|
||||
'[BREAKING CHANGE]',
|
||||
note,
|
||||
flags=re.IGNORECASE)
|
||||
note = re.sub(r"^'(az .*?)':", r"`\1`:", note)
|
||||
note = re.sub(r"^(az .*?):", r"`\1`:", note)
|
||||
if not note.startswith('az') and not ':' in note:
|
||||
note = note[0].capitalize() + note[1:]
|
||||
if note.endswith('.'):
|
||||
note = note[:-1]
|
||||
return component, note
|
||||
return None, None
|
||||
|
||||
|
||||
def pr_number_appended(line):
|
||||
m = re.search(r' \(#[0-9]+\)$', line)
|
||||
return m is not None
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
generate_history_notes()
|
||||
|
|
Загрузка…
Ссылка в новой задаче