Refactoring CHANGELOG generation process

This commit is contained in:
iratusmachina 2024-04-24 12:27:32 -04:00
parent 4a59bc6e88
commit 3fd905e3fa
2 changed files with 40 additions and 14 deletions

12
CHANGELOG.md Normal file
View File

@ -0,0 +1,12 @@
## v0.1.0 (2024-04-20)
* Refactoring draft notes generation [View](https://git.iratusmachina.com/iratusmachina/lyricdownloader/commits/6bb0da8f79b97e1a59b77cb59ba206db1cea9574)
* Refactoring draft notes generation [View](https://git.iratusmachina.com/iratusmachina/lyricdownloader/commits/a41ce583d39926b39f2ca4c10f4f901f8952e005)
* fixing errcheck errors [View](https://git.iratusmachina.com/iratusmachina/lyricdownloader/commits/1ff8fde8384a34b2286918cd194ba081addfdf83)
* Adding a new flag [View](https://git.iratusmachina.com/iratusmachina/lyricdownloader/commits/555dbc2e0ddcc4b4c256407883c2486ae750b680)
* Adding woodpecker build files [View](https://git.iratusmachina.com/iratusmachina/lyricdownloader/commits/879f7473942b3f6cbef79af909d3edc1c5d736cc)
* Able to scrape lyrics from Google Search [View](https://git.iratusmachina.com/iratusmachina/lyricdownloader/commits/38f64dcb9293ee5fce323d14083be9cc8d75e918)
* Adding LICENSE [View](https://git.iratusmachina.com/iratusmachina/lyricdownloader/commits/a17fe93f2ef8320db4d20cb9c7cab4a0888ea295)
* Adding simple Makefile [View](https://git.iratusmachina.com/iratusmachina/lyricdownloader/commits/23f3d3b1356e89c03114cf8ee840d8df18f98ef2)
* Initial config [View](https://git.iratusmachina.com/iratusmachina/lyricdownloader/commits/a4284d56ec78356a5a152e3cc860eed2c5957f1e)

View File

@ -21,21 +21,35 @@ def full():
# Remove the first occurence of the word git starting from the end of the string
remote_url = remote_url[0:remote_url.rfind(".git")]
previous_tag = ""
for tag in tags:
if previous_tag:
# Extract the date of the commit
tag_date = subprocess.check_output(["git", "log", "-1", f"--pretty=format:'%ad'", "--date=short", f"{tag}"], text=True)
tag_date = tag_date.replace("'", "")
if len(tags) == 1:
# Extract the date of the commit
tag_date = subprocess.check_output(["git", "log", "-1", f"--pretty=format:'%ad'", "--date=short", f"{tags[0]}"], text=True)
tag_date = tag_date.replace("'", "")
# Get each commit of a tag formatted
formatted_lines = subprocess.check_output(["git", "log", f"{tag}...{previous_tag}", f'--pretty=format:"* %s [View]({remote_url}/commits/%H)"'], text=True)
if formatted_lines:
fw.write(f"## {tag} ({tag_date})\n\n")
# Remove merge commits or Changelog commits
lines = "\n".join([line.replace("\"", "") for line in formatted_lines.split("\n") if all(["merge" not in line.lower(), "changelog.md" not in line.lower()])])
fw.write(lines)
fw.write("\n\n")
previous_tag = tag
# Get each commit of a tag formatted
formatted_lines = subprocess.check_output(["git", "log", f"{tags[0]}", f'--pretty=format:"* %s [View]({remote_url}/commits/%H)"'], text=True)
if formatted_lines:
fw.write(f"## {tags[0]} ({tag_date})\n\n")
# Remove merge commits or Changelog commits
lines = "\n".join([line.replace("\"", "") for line in formatted_lines.split("\n") if all(["merge" not in line.lower(), "changelog.md" not in line.lower()])])
fw.write(lines)
fw.write("\n\n")
else:
for tag in tags:
if previous_tag:
# Extract the date of the commit
tag_date = subprocess.check_output(["git", "log", "-1", f"--pretty=format:'%ad'", "--date=short", f"{tag}"], text=True)
tag_date = tag_date.replace("'", "")
# Get each commit of a tag formatted
formatted_lines = subprocess.check_output(["git", "log", f"{tag}...{previous_tag}", f'--pretty=format:"* %s [View]({remote_url}/commits/%H)"'], text=True)
if formatted_lines:
fw.write(f"## {tag} ({tag_date})\n\n")
# Remove merge commits or Changelog commits
lines = "\n".join([line.replace("\"", "") for line in formatted_lines.split("\n") if all(["merge" not in line.lower(), "changelog.md" not in line.lower()])])
fw.write(lines)
fw.write("\n\n")
previous_tag = tag
except subprocess.CalledProcessError as e:
print(f"Command failed with return code {e.returncode}")