mirror of
https://github.com/SerenityOS/serenity
synced 2026-04-25 17:15:42 +02:00
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.
25 lines
451 B
Bash
Executable File
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
|