Radish alpha
H
rad:z3QDZAW2FAfuLvihrhiyDC9fAD8G9
HardenedBSD Package Manager
Radicle
Git
update: show a warning when trying to update a non existent repository
Baptiste Daroussin committed 18 days ago
commit 65bb87ab6e7df4a9bc61012f0d76faafaf0154ba
parent e568f69
2 files changed +54 -0
modified src/update.c
@@ -102,6 +102,23 @@ pkgcli_update(bool force, bool strict, c_charv_t *reponames)
		total_count ++;
	}

+
	/* Warn about requested repos that don't exist */
+
	if (reponames->len > 0) {
+
		vec_foreach(*reponames, i) {
+
			struct pkg_repo *check = NULL;
+
			bool found = false;
+
			while (pkg_repos(&check) == EPKG_OK) {
+
				if (STREQ(reponames->d[i], pkg_repo_name(check))) {
+
					found = true;
+
					break;
+
				}
+
			}
+
			if (!found)
+
				fprintf(stderr, "WARNING: repository '%s' "
+
				    "does not exist\n", reponames->d[i]);
+
		}
+
	}
+

	if (total_count == 0) {
		retcode = EPKG_FATAL;
		if (!quiet) {
modified tests/frontend/update.sh
@@ -8,6 +8,7 @@ tests_init \
	update_disabled_repo \
	update_all_disabled_repos \
	update_override_disabled_repo \
+
	update_nonexistent_repo

update_error_body() {

@@ -178,6 +179,7 @@ EOF

	atf_check \
		-o match:"No repositories are enabled" \
+
		-e match:"WARNING: repository 'nonexistent' does not exist" \
		-s exit:1 \
		pkg -R repos update -r nonexistent
}
@@ -257,3 +259,38 @@ EOF
		-s exit:0 \
		pkg -R repos update -r myrepo
}
+

+
update_nonexistent_repo_body()
+
{
+
	# Specifying a nonexistent repo with -r should warn
+
	atf_check sh ${RESOURCEDIR}/test_subr.sh new_pkg "test" "test" "1"
+
	atf_check pkg create -M test.ucl
+
	atf_check -o ignore pkg repo .
+

+
	mkdir repos
+
	cat <<EOF > repos/real.conf
+
real: {
+
	url: "file://${TMPDIR}",
+
	enabled: true
+
}
+
EOF
+

+
	atf_check \
+
		-o match:"Updating real" \
+
		-s exit:0 \
+
		pkg -R repos update -r real
+

+
	# Update with a mix of real and nonexistent repos
+
	atf_check \
+
		-e match:"WARNING: repository 'bogus' does not exist" \
+
		-o match:"Updating real" \
+
		-s exit:0 \
+
		pkg -R repos update -r real -r bogus
+

+
	# Update with only a nonexistent repo
+
	atf_check \
+
		-o match:"No repositories are enabled" \
+
		-e match:"WARNING: repository 'bogus' does not exist" \
+
		-s exit:1 \
+
		pkg -R repos update -r bogus
+
}