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

Add git module #2

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
4 changes: 4 additions & 0 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
7 changes: 7 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -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
----------------------
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -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])

Expand Down
42 changes: 42 additions & 0 deletions git.subr
Original file line number Diff line number Diff line change
@@ -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
}
18 changes: 18 additions & 0 deletions man/shtk_git.3
Original file line number Diff line number Diff line change
@@ -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
19 changes: 19 additions & 0 deletions man/shtk_git_gethash.3
Original file line number Diff line number Diff line change
@@ -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
19 changes: 19 additions & 0 deletions man/shtk_git_pull.3
Original file line number Diff line number Diff line change
@@ -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