Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent tag refs in $(GitBranch) for detached heads. #127

Merged
merged 1 commit into from
Sep 24, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion src/GitInfo/build/GitInfo.targets
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,14 @@
will be used to find a base version.
Defaults to empty value (no ignoring).

$(GitNameRevOptions): Options passed to git name-rev when finding
a branch name for a commit (Detached head).
The default is '--refs=refs/heads/*'
meaning branch names only. For the legacy behavior where
$(GitBranch) for detached head can also be a tag name,
use '--refs=refs/*'.
Refs can be included and excluded, see git name-rev docs.

$(GitSkipCache): whether to cache the Git information determined
in a previous build in a GitInfo.cache for
performance reasons.
Expand Down Expand Up @@ -92,6 +100,8 @@

<GitCommitsIgnoreMerges Condition="'$(GitCommitsIgnoreMerges)' == ''">false</GitCommitsIgnoreMerges>

<GitNameRevOptions Condition="'$(GitNameRevOptions)' == ''">--refs=refs/heads/*</GitNameRevOptions>

<GitMinVersion>2.5.0</GitMinVersion>
</PropertyGroup>

Expand Down Expand Up @@ -428,7 +438,7 @@
</PropertyGroup>

<!-- CI systems may checkout the specific commit, rather than the branch, so we need to fallback -->
<Exec Command='$(GitExe) name-rev --name-only HEAD'
<Exec Command='$(GitExe) name-rev --name-only $(GitNameRevOptions) HEAD'
Condition=" '$(GitBranch)' == '' "
EchoOff='true'
StandardErrorImportance="low"
Expand Down
13 changes: 13 additions & 0 deletions src/GitInfo/readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -98,3 +98,16 @@ Available MSBuild customizations:
whether the branch and tags (if any)
will be used to find a base version.
Defaults to empty value (no ignoring).

$(GitNameRevOptions): Options passed to git name-rev when finding
a branch name for the current commit (Detached head).
The default is '--refs=refs/heads/*'
meaning branch names only. For legacy behavior where
$(GitBranch) for detached head can also be a tag name,
use '--refs=refs/*'.
Refs can be included and excluded, see git name-rev docs.

$(GitSkipCache): whether to cache the Git information determined
in a previous build in a GitInfo.cache for
performance reasons.
Defaults to empty value (no ignoring).