Skip to content

Conversation

datdenkikniet
Copy link
Contributor

@datdenkikniet datdenkikniet commented Sep 17, 2025

Instead of having bare, link-less references in our markdown files, we can have all of them! (And perhaps become better at linking new releases?)

Also, please squash this PR, I've just added each commit separately so it's not as messy.

Script:

Awful shell script
#!/bin/bash

# set -x

get_version() {
    revision="$1"
    file="$2"

    git show $revision:"$file" | grep "version =" | head -n 1 | cut -d ' ' -f3 | cut -d '"' -f2
}

get_commit() {
    revision="$1"
    file="$2"

    git blame --abbrev=40 $revision -- "$file" | grep "version = " | head -n 1 | cut -d ' ' -f1
}

file="$1"
changelog="$2"
current_commit=$(get_commit HEAD "$file")
current_version=$(get_version $current_commit "$file")

echo "Commit for v$current_version: $current_commit"

while [ $(git show $current_commit~1:"$file" > /dev/null 2>&1; echo $?) = "0" ]; do
    current_commit=$(get_commit $current_commit~1 "$file")
    current_version=$(get_version $current_commit "$file")

    tag=$(git describe $current_commit)
    echo "Commit for v$current_version: $current_commit."
    escaped_version=$(echo -n "$current_version" | sed "s/\\./\\\\./g")
    url="https://github.com/rtic-rs/rtic/commit/$current_commit"
    # I hate it, but it works :)
    sed -E -i "s@## (\\[v$escaped_version\\]|v$escaped_version)(.*)\$@## [v$current_version]($url)\\2@g" "$changelog"
done

@datdenkikniet
Copy link
Contributor Author

OK the script is doing some bad stuff, may fix it later (but not right now).

@datdenkikniet datdenkikniet marked this pull request as draft September 17, 2025 19:26
@AfoHT
Copy link
Contributor

AfoHT commented Sep 17, 2025

Interesting approach, if we disregard that the script at this moment isn't doing what you wanted it to do:

Isn't the git tags meant to make the unsightly hashes a bit more kind on those who need to edit the changelogs (currently imposed on all contributors, not just maintainers)?

It does happen that we forget to tag releases, but it's easy enough to rectify, even back-dating them is not that hard. Perhaps this step even helps us, and encourage proper tagged releases :)

I like this approach though, especially in contrast to that diff-thingy in the footer going back to the RTIC stone ages that was yanked not that long ago was too much bother for little gain xD

Added tags now for v2.1.2, v2.1.3 and v2.2.0 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants