Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Francesco Witz
Changelog Generator
Commits
726e8062
Commit
726e8062
authored
Feb 13, 2022
by
Francesco Witz
Browse files
feat: changelog generation
parent
e5b49b31
Changes
1
Hide whitespace changes
Inline
Side-by-side
chlog.py
View file @
726e8062
...
...
@@ -10,6 +10,7 @@ import string
from
datetime
import
datetime
,
timedelta
from
git_scrapper
import
*
from
file_generator
import
*
def
generate_changelog
(
project_path
:
str
):
"""
...
...
@@ -18,11 +19,32 @@ def generate_changelog(project_path: str):
print
(
project_path
)
check_update
()
# Checking if an update is available
check_chlog
(
project_path
=
project_path
)
# Checking if the config file is present on the project directory
# Get the last version in chlog.json to get the appropriate commit
# Check if changelog file exist
# If not, create it and ask for a short description to insert at the begining of the file
# Instanciate File object and generate version section
commits
=
get_formatted_commits
(
"v0.1.0"
)
print
(
"Beginning changelog generation... 🛠"
)
# Checking formatting of every commit before generation
correctly_formatted
=
check_formating
(
project_path
=
project_path
,
before_gen
=
True
)
# If all commit are correctly formatted
if
correctly_formatted
:
os
.
chdir
(
project_path
)
# Going to the project directory
# Get the last version in chlog.json to get the appropriate commit
with
open
(
"chlog.json"
,
"r"
)
as
chlog_file
:
chlog
=
json
.
load
(
chlog_file
)
version
=
chlog
[
"last-version"
]
commits
=
get_formatted_commits
(
version
)
# Check if changelog file exist
if
not
os
.
path
.
exists
(
"CHANGELOG.md"
):
# Creating it and ask for a short description to insert at the begining of the file
print
(
"No CHANGELOG.md file found, initializing it... 🛠"
)
with
open
(
"CHANGELOG.md"
,
'w'
)
as
md_file
:
to_write
:
list
[
str
]
=
[
"# Changelog
\n
"
,
"
\n
"
,
"All notable changes to this project will be documented in this file
\n
"
,
"
\n
"
]
md_file
.
writelines
(
to_write
)
# Instanciate File object
changelog
=
File
(
os
.
path
.
abspath
(
"CHANGELOG.md"
))
# Generate version section
print
(
"Writing changes... 🛠"
)
write_changes
(
project_path
,
changelog
,
commits
)
print
(
"Changelog now have a new section ! ✨"
)
else
:
print
(
"❌ Some commits don't respect formatting rule, correct them and retry."
)
def
versioning
(
args
,
project_path
:
str
):
...
...
@@ -242,7 +264,8 @@ def check_formating(project_path: str, before_gen: bool):
return
False
print
(
"
\n
Check finished ! ✨"
)
# Explain to user how to edit the commits with git
print
(
"ℹ You can edit your commit messages using the interactive version of the git rebase command !"
)
if
not
before_gen
:
print
(
"ℹ You can edit your commit messages using the interactive version of the git rebase command !"
)
def
rules
():
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment