Project

General

Profile

Actions

Bug #14011

open

build/run-library.sh version_from_git function dumps environment when not in a git repo

Added by Joshua Randall over 5 years ago. Updated 27 days ago.

Status:
New
Priority:
Normal
Assigned To:
-
Category:
Deployment
Target version:
Story points:
-
Release:
Release relationship:
Auto

Description

there is a bug in build/run-library.sh version_from_git function.

if we are running not in a git repo, the `format_last_commit_here` function returns nothing, and as a result the line:

    declare $(format_last_commit_here "git_ts=%ct git_hash=%h")

Ends up being equivalent to `declare` which dumps the environment.

I believe the fix should be to quote it:

    declare "$(format_last_commit_here 'git_ts=%ct git_hash=%h')" 

Actions #1

Updated by Joshua Randall over 5 years ago

The above fix doesn't work as the quoted version is not interpreted correctly by declare when it is actually run in a git repo.

A fix for this could be to ensure `format_last_commit_here` always returns variable declarations or else exits when git fails - something like:

format_last_commit_here() {
    local format="$1"; shift
    TZ=UTC git log -n1 --first-parent "--format=format:$format" . || (echo "git log command failed - is $(pwd) a git repo?"; exit 1)
}

Or I suppose the version_from_git function could do a sanity check first to make sure it is, in fact, in a git repo.

Actions #2

Updated by Joshua Randall over 5 years ago

That example doesn't work either, because subshells.

Now trying this:

declare x=1 $(format_last_commit_here "git_ts=%ct git_hash=%h")

Actions #3

Updated by Peter Amstutz about 1 year ago

  • Release set to 60
Actions #4

Updated by Peter Amstutz 27 days ago

  • Target version set to Future
Actions

Also available in: Atom PDF