From 1e0e2f475d5ec58684e3e92530df49b6aba22050 Mon Sep 17 00:00:00 2001 From: Daniel Cazzulino Date: Tue, 29 Oct 2024 15:01:00 -0300 Subject: [PATCH] Set default GitBranch from CI env variables Virtually all CI systems provide environment variables containing the branch from the underlying source control. This is already in use in: https://github.com/dotnet/reproducible-builds/pull/ https://github.com/devlooped/oss/issues/2 https://github.com/devlooped/nugetizer/issues/57 https://github.com/devlooped/ThisAssembly/issues/69 We should also bring in the same defaults here. Hopefully this will one day be part of SourceLink. --- src/GitInfo/build/GitInfo.CI.targets | 36 ++++++++++++++++++++++++++++ src/GitInfo/build/GitInfo.targets | 14 +++++++++++ 2 files changed, 50 insertions(+) create mode 100644 src/GitInfo/build/GitInfo.CI.targets diff --git a/src/GitInfo/build/GitInfo.CI.targets b/src/GitInfo/build/GitInfo.CI.targets new file mode 100644 index 0000000..25ec7c7 --- /dev/null +++ b/src/GitInfo/build/GitInfo.CI.targets @@ -0,0 +1,36 @@ + + + + + + pr$(GITHUB_REF.Replace('refs/pull/', '').Replace('/merge', '')) + $(GITHUB_REF.Replace('refs/heads/', '').Replace('refs/tags/', '')) + + $(BUILD_SOURCEBRANCH.Replace('refs/heads/', '').Replace('refs/tags/', '')) + + pr$(APPVEYOR_PULL_REQUEST_NUMBER) + $(APPVEYOR_REPO_TAG_NAME) + $(APPVEYOR_REPO_BRANCH) + + $(TEAMCITY_BUILD_BRANCH) + + pr$(TRAVIS_PULL_REQUEST) + $(TRAVIS_BRANCH) + + pr$(CIRCLE_PR_NUMBER) + $(CIRCLE_TAG) + $(CIRCLE_BRANCH) + + $(CI_COMMIT_TAG) + pr$(CI_MERGE_REQUEST_IID) + pr$(CI_EXTERNAL_PULL_REQUEST_IID) + $(CI_COMMIT_BRANCH) + + pr$(BUDDY_EXECUTION_PULL_REQUEST_NO) + $(BUDDY_EXECUTION_TAG) + $(BUDDY_EXECUTION_BRANCH) + + $(GIT_LOCAL_BRANCH) + + + \ No newline at end of file diff --git a/src/GitInfo/build/GitInfo.targets b/src/GitInfo/build/GitInfo.targets index 9d758cc..5ffec3a 100644 --- a/src/GitInfo/build/GitInfo.targets +++ b/src/GitInfo/build/GitInfo.targets @@ -104,6 +104,20 @@ <_GitIsDirtyFile>$(GitCachePath)GitIsDirty.cache + + false + + true + + + +