daemon: make deploy work for local branches

We would unconditionally call ostree's pull() regardless of whether the
branch we were tracking was remote or not. We need this to work to make
it easier to write tests, though it's a worthy addition on its own.

Closes: #371
Approved by: cgwalters
This commit is contained in:
Jonathan Lebon 2016-06-30 12:41:20 -04:00 committed by Atomic Bot
parent ff5dee43fb
commit 77acf62274

View File

@ -283,9 +283,12 @@ rpmostreed_repo_pull_ancestry (OstreeRepo *repo,
refs_array[0] = ref;
while (TRUE)
{
if (remote != NULL)
{
/* Floating reference, transferred to dictionary. */
refs_value = g_variant_new_strv ((const char * const *) refs_array, -1);
refs_value =
g_variant_new_strv ((const char * const *) refs_array, -1);
g_variant_dict_init (&options, NULL);
g_variant_dict_insert (&options, "depth", "i", depth);
@ -296,6 +299,7 @@ rpmostreed_repo_pull_ancestry (OstreeRepo *repo,
g_variant_dict_end (&options),
progress, cancellable, error))
goto out;
}
/* First pass only. Now we can resolve the ref to a checksum. */
if (checksum == NULL)
@ -304,13 +308,15 @@ rpmostreed_repo_pull_ancestry (OstreeRepo *repo,
goto out;
}
/* If depth is negative (no visitor), this loop is skipped. */
if (visitor != NULL)
{
for (ii = 0; ii < depth && checksum != NULL; ii++)
{
g_autoptr(GVariant) commit = NULL;
gboolean stop = FALSE;
if (!ostree_repo_load_commit (repo, checksum, &commit, NULL, error))
if (!ostree_repo_load_commit (repo, checksum, &commit,
NULL, error))
goto out;
if (!visitor (repo, checksum, commit, visitor_data, &stop, error))
@ -321,9 +327,10 @@ rpmostreed_repo_pull_ancestry (OstreeRepo *repo,
if (!stop)
checksum = ostree_commit_get_parent (commit);
}
}
/* Break if no visitor, or visitor told us to stop. */
if (depth < 0 || checksum == NULL)
if (visitor == NULL || checksum == NULL)
break;
/* Pull the next batch of commits, twice as many. */