Skip to content
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
28 changes: 16 additions & 12 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,53 +8,57 @@ jobs:
steps:
- uses: actions/checkout@v4
- run: sudo apt-get install bash
- run: sudo apt-get remove git
- run: ./.github/workflows/build.sh bash ""

bash-cvs:
bash-everything:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: sudo apt-get install bash cvs
- run: ./.github/workflows/build.sh bash "cvs"
- run: sudo apt-get install bash cvs git
- run: ./.github/workflows/build.sh bash "cvs git"

dash-nothing:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: sudo apt-get install dash
- run: sudo apt-get remove git
- run: ./.github/workflows/build.sh dash ""

dash-cvs:
dash-everything:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: sudo apt-get install dash cvs
- run: ./.github/workflows/build.sh dash "cvs"
- run: sudo apt-get install dash cvs git
- run: ./.github/workflows/build.sh dash "cvs git"

mksh-nothing:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: sudo apt-get install mksh
- run: sudo apt-get remove git
- run: ./.github/workflows/build.sh ksh ""

mksh-cvs:
mksh-everything:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: sudo apt-get install mksh cvs
- run: ./.github/workflows/build.sh ksh "cvs"
- run: sudo apt-get install mksh cvs git
- run: ./.github/workflows/build.sh ksh "cvs git"

zsh-nothing:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: sudo apt-get install zsh
- run: sudo apt-get remove git
- run: ./.github/workflows/build.sh zsh ""

zsh-cvs:
zsh-everything:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: sudo apt-get install zsh cvs
- run: ./.github/workflows/build.sh zsh "cvs"
- run: sudo apt-get install zsh cvs git
- run: ./.github/workflows/build.sh zsh "cvs git"
12 changes: 12 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 @@ -123,6 +124,10 @@ 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_clone.3
dist_man_MANS += man/shtk_git_fetch.3
dist_man_MANS += man/shtk_git_update.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 Expand Up @@ -216,6 +221,13 @@ EXTRA_DIST += fs_test.sh
fs_test: $(srcdir)/fs_test.sh shtk
$(AM_V_GEN)name=fs_test; $(BUILD_TEST)

TESTS += git_test
check_SCRIPTS += git_test
CLEANFILES += git_test
EXTRA_DIST += git_test.sh
git_test: $(srcdir)/git_test.sh shtk
$(AM_V_GEN)name=git_test; $(BUILD_TEST)

TESTS += hw_test
check_SCRIPTS += hw_test
CLEANFILES += hw_test
Expand Down
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ Changes in version 1.8

* Migrated to using Automake to run shtk's own test suite instead of Kyua.

* Added support for git.


Changes in version 1.7
----------------------
Expand Down
69 changes: 69 additions & 0 deletions git.subr
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# Copyright 2025 Julio Merino
# 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.
#
# 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 bool
shtk_import cli
shtk_import process


shtk_git_fetch() {
local repo="${1}"; shift
local branch="${1}"; shift
local directory="${1}"; shift

if [ -d "${directory}" ]; then
shtk_git_update "${branch}" "${directory}"
else
shtk_git_clone "${repo}" "${branch}" "${directory}"
fi
}


shtk_git_clone() {
local repo="${1}"; shift
local branch="${1}"; shift
local directory="${1}"; shift

[ ! -d "${directory}" ] || shtk_cli_error "Cannot clone into" \
"${directory}; directory already exists"
shtk_process_run git clone -b "${branch}" "${repo}" \
"${directory}" || shtk_cli_error "git clone failed"
}


shtk_git_update() {
local branch="${1}"; shift
local directory="${1}"; shift

[ -d "${directory}" ] || shtk_cli_error "Cannot update ${directory};" \
"directory does not exist"

shtk_process_run -w "${directory}" git fetch origin "${branch}" \
|| shtk_cli_error "git update failed"
shtk_process_run -w "${directory}" git checkout "${branch}" \
|| shtk_cli_error "git update failed"
shtk_process_run -w "${directory}" git merge --ff-only "origin/${branch}" \
|| shtk_cli_error "git update failed"
}
Loading
Loading