mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-08-28 04:21:03 +00:00
packaging: Add get_last_modification()
Let's add a function to get the hash of the last commit modifying a specific file. This will help to avoid writing `git rev-list ...` into every single build script used by the kata-deploy. Signed-off-by: Fabiano Fidêncio <fabiano.fidencio@intel.com>
This commit is contained in:
parent
fa1bf8f75c
commit
b1454dbcaa
@ -113,4 +113,19 @@ get_config_version() {
|
|||||||
else
|
else
|
||||||
die "failed to find ${config_version_file}"
|
die "failed to find ${config_version_file}"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# $1 - Repo's root dir
|
||||||
|
# $2 - The file we're looking for the last modification
|
||||||
|
get_last_modification() {
|
||||||
|
local repo_root_dir="${1}"
|
||||||
|
local file="${2}"
|
||||||
|
|
||||||
|
# This is a workaround needed for when running this code on Jenkins
|
||||||
|
git config --global --add safe.directory ${repo_root_dir} &> /dev/null
|
||||||
|
|
||||||
|
dirty=""
|
||||||
|
[ $(git status --porcelain | grep "${file}" | wc -l) -gt 0 ] && dirty="-dirty"
|
||||||
|
|
||||||
|
echo "$(git log -1 --pretty=format:"%H" ${file})${dirty}"
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user