Files
serenity/Kernel/generate-version-file.sh
Sönke Holz cd55bcfa00 Kernel: Use git describe to generate git hash
Instead of manually creating the git hash string, we can simply use
`git describe` with appropriate options:

- `--exclude '*'` to exclude any git tags
- `--always` to make `git describe` print a uniquely abbreviated
  commit hash if no tag is matching
- `--dirty=-modified` to add a "-modified" suffix if the working tree
  has local modifications

This should also guarantee now that the abbreviated commit hash is
always unique. Previously, we always abbreviated the commit hash to 7
characters.
2025-10-11 10:48:50 -04:00

25 lines
451 B
Bash
Executable File

#!/bin/sh
set -e
OUTPUT_FILE=$1
GIT_HASH=$(git describe --exclude '*' --always --dirty=-modified 2>/dev/null || echo "unknown")
cat << EOF > "$OUTPUT_FILE"
/*
* Automatically generated by Kernel/generate-version-file.sh
*/
#pragma once
#include <AK/StringView.h>
namespace Kernel {
constexpr unsigned SERENITY_MAJOR_REVISION = 1;
constexpr unsigned SERENITY_MINOR_REVISION = 0;
constexpr StringView SERENITY_VERSION = "${GIT_HASH}"sv;
}
EOF