-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add script and VSCode task for creating change notes
Adds a VSCode Task (accessible from the "Run Task" menu) for creating change notes, prompting the user for the language, name, and category of the change. The language options presented are based on the existing occurrences of `change-notes` folders in the repo. There are more such files (in particular every shared library has a `change-notes` directory), but it seemed to me that the language change notes are the ones that are most common, and so in an effort to not clutter the list too much, I only included the languages. The selection of categories is based on existing usage -- more specifically the result of grepping for occurrences of '^category: ' in the repo. It's possible there are more change categories that could be added. Hopefully this should make it more convenient to create change notes from within VSCode.
- Loading branch information
Showing
2 changed files
with
103 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
#!/usr/bin/env python3 | ||
|
||
# Creates a change note and opens it in VSCode for editing. | ||
|
||
# Expects to receive the following arguments: | ||
# - What language the change note is for | ||
# - The name of the change note (in kebab-case) | ||
# - The category of the change. | ||
|
||
# The change note will be created in the `{language}/ql/lib/change-notes` directory. | ||
|
||
# The format of the change note filename is `{current_date}-{change_note_name}.md` with the date in | ||
# the format `YYYY-MM-DD`. | ||
|
||
import sys | ||
import os | ||
|
||
# Read the given arguments | ||
language = sys.argv[1] | ||
change_note_name = sys.argv[2] | ||
change_category = sys.argv[3] | ||
|
||
# Find the root of the repository. The current script should be located in `misc/scripts`. | ||
root = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) | ||
|
||
# Go to the repo root | ||
os.chdir(root) | ||
|
||
# Abort if the output directory doesn't exist | ||
if not os.path.exists(f"{language}/ql/lib/change-notes"): | ||
print(f"Output directory {language}/ql/lib/change-notes does not exist") | ||
sys.exit(1) | ||
|
||
# Get the current date | ||
import datetime | ||
current_date = datetime.datetime.now().strftime("%Y-%m-%d") | ||
|
||
# Create the change note file | ||
change_note_file = f"{language}/ql/lib/change-notes/{current_date}-{change_note_name}.md" | ||
|
||
change_note = f""" | ||
--- | ||
category: {change_category} | ||
--- | ||
* """.lstrip() | ||
|
||
with open(change_note_file, "w") as f: | ||
f.write(change_note) | ||
|
||
# Open the change note file in VSCode, reusing the existing window if possible | ||
os.system(f"code -r {change_note_file}") |