summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorSebastian Holmin <sebastian.holmin@mullvad.net>2024-05-03 10:51:45 +0200
committerSebastian Holmin <sebastian.holmin@mullvad.net>2024-05-16 02:04:18 +0200
commit7f7b95ba115a2edc8e3c66639ce9babecbce483c (patch)
tree8856e93959ef56c373d774248698dc9125c56dc7
parent57568b339518a1a8513a0e5dd8bfdf118dd4fb1e (diff)
downloadmullvadvpn-7f7b95ba115a2edc8e3c66639ce9babecbce483c.tar.xz
mullvadvpn-7f7b95ba115a2edc8e3c66639ce9babecbce483c.zip
Add comments explaining the files we are tracking
Also add a note on the `.git/packed-refs` file and why we don't need to track it.
-rw-r--r--mullvad-version/build.rs19
1 files changed, 15 insertions, 4 deletions
diff --git a/mullvad-version/build.rs b/mullvad-version/build.rs
index fc7eb9edbe..5d89044869 100644
--- a/mullvad-version/build.rs
+++ b/mullvad-version/build.rs
@@ -101,14 +101,17 @@ fn get_dev_suffix(release_tag: &str) -> Option<String> {
fn rerun_if_git_ref_changed(release_tag: &str) -> std::io::Result<()> {
let git_dir = Path::new("..").join(".git");
- // If we build our output on information about HEAD we need to re-run if HEAD moves
+ // The `.git/HEAD` file contains the position of the current head. If in 'detached HEAD' state,
+ // this will be the ref of the current commit. If on a branch it will just point to it, e.g.
+ // `ref: refs/heads/main`. Tracking changes to this file will tell us if we change branch, or
+ // modify the current detached HEAD state (e.g. committing or rebasing).
let head_path = git_dir.join("HEAD");
if head_path.exists() {
println!("cargo:rerun-if-changed={}", head_path.display());
}
- // If we build our output on information about the ref of the current branch, we need to re-run
- // on changes to it
+ // The above check will not cause a rebuild when modifying commits on a currently checked out
+ // branch. To catch this, we need to track the `.git/refs/heads/$current_branch` file.
let output = Command::new("git")
.arg("branch")
.arg("--show-current")
@@ -135,7 +138,15 @@ fn rerun_if_git_ref_changed(release_tag: &str) -> std::io::Result<()> {
if git_release_tag_ref.exists() {
println!("cargo:rerun-if-changed={}", git_release_tag_ref.display());
};
- Some(())
+
+ // NOTE: As the repository has gotten quite large, you may find the contents of the
+ // `.git/refs/heads` and `.git/refs/tags` empty. This happens because `git pack-refs` compresses
+ // and moves the information into the `.git/packed-refs` file to save storage. We do not have to
+ // track this file, however, as any changes to the current branch, 'detached HEAD' state
+ // or tags will update the corresponding `.git/refs` file we are tracking, even if it had
+ // previously been pruned.
+
+ Ok(())
}
/// Returns the commit hash for the commit that `git_ref` is pointing to.