Radish alpha
H
rad:z3QDZAW2FAfuLvihrhiyDC9fAD8G9
HardenedBSD Package Manager
Radicle
Git
set: relax syntax for origin and fix typo
Baptiste Daroussin committed 8 months ago
commit 75900923260eaf40f886098c178a39fcc31de0ef
parent cdfe20d
3 files changed +74 -3
modified libpkg/pkgdb.c
@@ -2534,7 +2534,7 @@ pkgdb_replace(struct pkgdb *db, unsigned int field, const char *pattern, const c
	sqlite3_bind_text(stmt, 1, pattern, -1, SQLITE_STATIC);
	sqlite3_bind_text(stmt, 2, replace, -1, SQLITE_STATIC);
	xasprintf(&globmatch, "*%s*", pattern);
-
	sqlite3_bind_text(stmt, 2, globmatch, -1, SQLITE_STATIC);
+
	sqlite3_bind_text(stmt, 3, globmatch, -1, SQLITE_STATIC);
	pkgdb_debug(4, stmt);
	if (sqlite3_step(stmt) != SQLITE_DONE) {
		free(globmatch);
modified src/set.c
@@ -152,7 +152,7 @@ exec_set(int argc, char **argv)
			loads |= PKG_LOAD_DEPS;
			match = MATCH_ALL;
			changed = "origin";
-
			if (!check_change_values(optarg, &oldvalue, &newvalue, '/')) {
+
			if (!check_change_values(optarg, &oldvalue, &newvalue, '\0')) {
				 errx(EXIT_FAILURE, "Wrong format for -o. "
					 "Expecting oldorigin:neworigin, got: %s",
					 optarg);
modified tests/frontend/set.sh
@@ -6,7 +6,8 @@ tests_init \
	set_automatic \
	set_change_name \
	set_change_origin \
-
	set_vital
+
	set_vital \
+
	set_partial

initialize_pkg() {

@@ -119,3 +120,73 @@ set_vital_body() {
		-s exit:0 \
		pkg query "%V" test
}
+

+
set_partial_body() {
+
	initialize_pkg
+

+
	rm test.ucl
+
	atf_check -s exit:0 sh ${RESOURCEDIR}/test_subr.sh new_pkgf test plop-test origin/plop-test 1 /prefix
+

+
	atf_check \
+
		-o match:".*Installing.*\.\.\.$" \
+
		-e empty \
+
		-s exit:0 \
+
		pkg register -t -M test.ucl
+

+
	atf_check -s exit:0 sh ${RESOURCEDIR}/test_subr.sh new_pkgf test plop-foo origin/plop-foo 1 /prefix
+

+
	atf_check \
+
		-o match:".*Installing.*\.\.\.$" \
+
		-e empty \
+
		-s exit:0 \
+
		pkg register -t -M test.ucl
+

+
	atf_check \
+
		-o inline:"plop-foo-1\nplop-test-1\ntest-1\n" \
+
		-e empty \
+
		-s exit:0 \
+
		pkg info -q
+

+
	atf_check \
+
		-o inline:"2 packages have been renamed.\n" \
+
		-e empty \
+
		-s exit:0 \
+
		pkg set -ypn test:bla
+

+
	atf_check \
+
		-o inline:"bla-1\nplop-bla-1\nplop-foo-1\n" \
+
		-e empty \
+
		-s exit:0 \
+
		pkg info -q
+

+
	atf_check \
+
		-o inline:"2 packages have been renamed.\n" \
+
		-e empty \
+
		-s exit:0 \
+
		pkg set -ypn bla:test
+

+
	atf_check \
+
		-o inline:"plop-foo-1\nplop-test-1\ntest-1\n" \
+
		-e empty \
+
		-s exit:0 \
+
		pkg info -q
+

+
	atf_check \
+
		-o inline:"origin/plop-foo\norigin/plop-test\norigin/test\n" \
+
		-e empty \
+
		-s exit:0 \
+
		pkg info -qo
+

+
	atf_check \
+
		-o inline:"2 packages have been renamed.\n" \
+
		-e empty \
+
		-s exit:0 \
+
		pkg set -ypo test:bla
+

+
	atf_check \
+
		-o inline:"origin/plop-foo\norigin/plop-bla\norigin/bla\n" \
+
		-e empty \
+
		-s exit:0 \
+
		pkg info -qo
+

+
}