2015-04-02 13:33:07 +03:00
#!/bin/bash
#
# Copyright (C) 2011 Colin Walters <walters@verbum.org>
# Copyright (C) 2015 Red Hat, Inc.
#
2018-01-30 22:26:26 +03:00
# SPDX-License-Identifier: LGPL-2.0+
#
2015-04-02 13:33:07 +03:00
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the
# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
# Boston, MA 02111-1307, USA.
2016-01-27 19:44:10 +03:00
set -euo pipefail
2015-04-02 13:33:07 +03:00
2016-03-02 18:28:04 +03:00
echo "1..4"
2015-04-02 13:33:07 +03:00
. $( dirname $0 ) /libtest.sh
setup_test_repository "bare"
echo "ok setup"
2018-07-14 01:53:21 +03:00
# Check that without commit-update-summary set, creating a commit doesn't update the summary
2015-04-02 13:33:07 +03:00
mkdir test
echo hello > test/a
2016-05-13 21:38:50 +03:00
$OSTREE commit -b test -s "A commit" test
2015-04-02 13:33:07 +03:00
echo "ok commit 1"
2016-05-13 21:38:50 +03:00
$OSTREE summary --update
2015-04-02 13:33:07 +03:00
OLD_MD5 = $( md5sum repo/summary)
echo hello2 > test/a
2016-05-13 21:38:50 +03:00
$OSTREE commit -b test -s "Another commit" test
2015-04-02 13:33:07 +03:00
echo "ok commit 2"
2015-04-24 16:42:28 +03:00
assert_streq " $OLD_MD5 " " $( md5sum repo/summary) "
2015-04-02 13:33:07 +03:00
2018-07-14 01:53:21 +03:00
# Check that with commit-update-summary set, creating a commit updates the summary
2016-05-13 21:38:50 +03:00
$OSTREE --repo= repo config set core.commit-update-summary true
2015-04-02 13:33:07 +03:00
echo hello3 > test/a
2016-05-13 21:38:50 +03:00
$OSTREE commit -b test -s "Another commit..." test
2015-04-02 13:33:07 +03:00
echo "ok commit 3"
2015-04-24 16:42:28 +03:00
assert_not_streq " $OLD_MD5 " " $( md5sum repo/summary) "
2015-05-04 12:05:23 +03:00
2018-07-14 01:53:21 +03:00
$OSTREE --repo= repo config set core.commit-update-summary false
2015-05-04 12:05:23 +03:00
# Check that summary --update deletes the .sig file
touch repo/summary.sig
2016-05-13 21:38:50 +03:00
$OSTREE summary --update
2015-05-04 12:05:23 +03:00
assert_not_has_file repo/summary.sig
2018-07-14 01:53:21 +03:00
2018-07-30 17:46:58 +03:00
# Check that without auto-update-summary set, adding, changing, or deleting a ref doesn't update the summary
2018-07-14 01:53:21 +03:00
$OSTREE summary --update
OLD_MD5 = $( md5sum repo/summary)
$OSTREE commit -b test2 -s "A commit" test
assert_streq " $OLD_MD5 " " $( md5sum repo/summary) "
$OSTREE reset test test^
assert_streq " $OLD_MD5 " " $( md5sum repo/summary) "
$OSTREE refs --delete test
assert_streq " $OLD_MD5 " " $( md5sum repo/summary) "
2018-07-30 17:46:58 +03:00
# Check that with auto-update-summary set, adding, changing, or deleting a ref updates the summary
$OSTREE --repo= repo config set core.auto-update-summary true
2018-07-14 01:53:21 +03:00
$OSTREE summary --update
OLD_MD5 = $( md5sum repo/summary)
echo hello > test/a
$OSTREE commit -b test -s "A commit" test
echo hello2 > test/a
$OSTREE commit -b test -s "Another commit" test
assert_not_streq " $OLD_MD5 " " $( md5sum repo/summary) "
OLD_MD5 = $( md5sum repo/summary)
$OSTREE reset test test^
assert_not_streq " $OLD_MD5 " " $( md5sum repo/summary) "
OLD_MD5 = $( md5sum repo/summary)
$OSTREE refs --delete test
assert_not_streq " $OLD_MD5 " " $( md5sum repo/summary) "