From befa7878645fd826b0005f31cce9be139401e427 Mon Sep 17 00:00:00 2001 From: builder Date: Sat, 22 Feb 2020 20:03:21 +0100 Subject: [PATCH] Add git module Very small module created only to enable sysbuild to support git. --- Makefile.am | 4 ++++ NEWS.md | 7 +++++++ README.md | 1 + configure.ac | 2 +- git.subr | 42 ++++++++++++++++++++++++++++++++++++++++++ man/shtk_git.3 | 18 ++++++++++++++++++ man/shtk_git_gethash.3 | 19 +++++++++++++++++++ man/shtk_git_pull.3 | 19 +++++++++++++++++++ 8 files changed, 111 insertions(+), 1 deletion(-) create mode 100644 git.subr create mode 100644 man/shtk_git.3 create mode 100644 man/shtk_git_gethash.3 create mode 100644 man/shtk_git_pull.3 diff --git a/Makefile.am b/Makefile.am index 081ea7b..ab8bcdf 100644 --- a/Makefile.am +++ b/Makefile.am @@ -40,6 +40,7 @@ dist_pkgdata_DATA += cli.subr dist_pkgdata_DATA += config.subr dist_pkgdata_DATA += cvs.subr dist_pkgdata_DATA += fs.subr +dist_pkgdata_DATA += git.subr dist_pkgdata_DATA += hw.subr dist_pkgdata_DATA += list.subr dist_pkgdata_DATA += process.subr @@ -122,6 +123,9 @@ dist_man_MANS += man/shtk_cvs_update.3 dist_man_MANS += man/shtk_fs.3 dist_man_MANS += man/shtk_fs_join_paths.3 dist_man_MANS += man/shtk_fs_normalize_path.3 +dist_man_MANS += man/shtk_git.3 +dist_man_MANS += man/shtk_git_pull.3 +dist_man_MANS += man/shtk_git_gethash.3 dist_man_MANS += man/shtk_hw.3 dist_man_MANS += man/shtk_hw_ncpus.3 dist_man_MANS += man/shtk_list.3 diff --git a/NEWS.md b/NEWS.md index 5bdb9df..835365a 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,6 +1,13 @@ Major changes between releases ============================== +Changes in version 1.7.1 +---------------------- + +**Released on 2020-02-20.** + +* Added minimal support for git: pull, gethash + for sysbuild update. Changes in version 1.7 ---------------------- diff --git a/README.md b/README.md index 9088b42..2688465 100644 --- a/README.md +++ b/README.md @@ -69,6 +69,7 @@ As a quick introduction, here are the modules supplied by `shtk`: interfaces, including logging primitives. * `config`: Configuration file parser. * `cvs`: Utilities to interact with the CVS version control system. +* `git`: Utilities to interact with the Git distributed version control system. * `list`: Utilities to manipulate lists represented as a collection of arguments. * `process`: Utilities to execute external processes. diff --git a/configure.ac b/configure.ac index 90bda46..720fb4a 100644 --- a/configure.ac +++ b/configure.ac @@ -26,7 +26,7 @@ dnl THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT dnl (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE dnl OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -AC_INIT([Shell Toolkit], [1.7], +AC_INIT([Shell Toolkit], [1.7.1], [https://github.com/jmmv/shtk/issues/], [shtk], []) AC_PREREQ([2.65]) diff --git a/git.subr b/git.subr new file mode 100644 index 0000000..0c086d5 --- /dev/null +++ b/git.subr @@ -0,0 +1,42 @@ +# Copyright 2012 Google Inc. +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are +# met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of Google Inc. nor the names of its contributors +# may be used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +shtk_import cli +shtk_import process + +shtk_git_pull() { + local directory="${1}"; shift + + shtk_process_run git -C "${directory}" pull +} + +shtk_git_gethash() { + local directory="${1}"; shift + + shtk_process_run git -C "${directory}" log --pretty=format:"%h" -n1 +} diff --git a/man/shtk_git.3 b/man/shtk_git.3 new file mode 100644 index 0000000..1051558 --- /dev/null +++ b/man/shtk_git.3 @@ -0,0 +1,18 @@ +.Dd February 20, 2020 +.Dt SHTK_GIT 3 +.Os +.Sh NAME +.Nm git +.Nd Utilities to invoke GIT and wrappers to simplify its operation +.Sh LIBRARY +shtk_import +.Nm +.Sh DESCRIPTION +The +.Nm +module provides utilities to invoke the GIT utility and to simplify its +operation. +.Sh SEE ALSO +.Xr shtk 3 , +.Xr shtk_git_pull 3 , +.Xr shtk_git_gethash 3 diff --git a/man/shtk_git_gethash.3 b/man/shtk_git_gethash.3 new file mode 100644 index 0000000..e586838 --- /dev/null +++ b/man/shtk_git_gethash.3 @@ -0,0 +1,19 @@ +.Dd February 20, 2020 +.Dt SHTK_GIT_GETHASH 3 +.Os +.Sh NAME +.Nm shtk_git_gethash +.Nd get the commit's hash of the last commit on the local branch +.Sh LIBRARY +shtk_import git +.Sh SYNOPSIS +.Nm +.Ar directory +.Sh DESCRIPTION +The +.Nm +function is a call to 'git log --pretty=format:%h -n1' inside the +.Ar directory . +.Sh SEE ALSO +.Xr shtk 3 , +.Xr shtk_git 3 diff --git a/man/shtk_git_pull.3 b/man/shtk_git_pull.3 new file mode 100644 index 0000000..1006acf --- /dev/null +++ b/man/shtk_git_pull.3 @@ -0,0 +1,19 @@ +.Dd February 22, 2020 +.Dt SHTK_GIT_PULL 3 +.Os +.Sh NAME +.Nm shtk_git_pull +.Nd Pulls a Git repository +.Sh LIBRARY +shtk_import git +.Sh SYNOPSIS +.Nm +.Ar directory +.Sh DESCRIPTION +The +.Nm +function is a simple call to git pull inside the +.Ar directory . +.Sh SEE ALSO +.Xr shtk 3 , +.Xr shtk_git 3