Skip to content
This repository was archived by the owner on Oct 24, 2025. It is now read-only.
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
16 changes: 16 additions & 0 deletions source/summit/fixtures.d
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,14 @@ static void loadFixtures(ServiceContext context, ProjectManager projectManager)
auto l = project.bySlug(repo.name);
if (l !is null)
{
// Check if URI needs updating
if (l.model.originURI != repo.uri)
{
auto m = l.model;
m.originURI = repo.uri;
immutable err = project.updateRepository(m);
enforceHTTP(err.isNull, HTTPStatus.internalServerError, err.message);
}
continue;
}
Repository r;
Expand All @@ -105,6 +113,14 @@ static void loadFixtures(ServiceContext context, ProjectManager projectManager)
auto l = project.profile(profile.name);
if (l !is null)
{
// Check if URI needs updating
if (l.profile.volatileIndexURI != profile.indexURI)
{
auto m = l.profile;
m.volatileIndexURI = profile.indexURI;
immutable err = project.updateProfile(m);
enforceHTTP(err.isNull, HTTPStatus.internalServerError, err.message);
}
continue;
}

Expand Down
60 changes: 58 additions & 2 deletions source/summit/projects/project.d
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public final class ManagedProject
{
@disable this();

/**
/**
* Construct a new ManagedProject
*
* Params:
Expand Down Expand Up @@ -75,7 +75,7 @@ public final class ManagedProject
return managedProfiles.values;
}

/**
/**
* Returns: Repository within this project
*
* Params:
Expand Down Expand Up @@ -160,6 +160,34 @@ public final class ManagedProject
f.message)));
}

/**
* Update a repository in this project
*
* Params:
* model = Input model
* Returns: Nullable database error
*/
DatabaseResult updateRepository(Repository model) @safe
{
/* Try to store the model */
immutable err = context.appDB.update((scope tx) => model.save(tx));
if (!err.isNull)
{
return err;
}

/* Get it managed */
auto managedRepository = managedRepos.get(model.name, null);
if (managedRepository is null)
{
return DatabaseResult(DatabaseError(DatabaseErrorCode.BucketNotFound,
"Repository not found"));
}

runTask({ managedRepository.refresh(); });
return NoDatabaseError;
}

/**
* Add a profile to this project
*
Expand Down Expand Up @@ -193,6 +221,34 @@ public final class ManagedProject
f.message)));
}

/**
* Update a profile in this project
*
* Params:
* model = Input model
* Returns: Nullable database error
*/
DatabaseResult updateProfile(Profile model) @safe
{
/* Try to store the model */
immutable err = context.appDB.update((scope tx) => model.save(tx));
if (!err.isNull)
{
return err;
}

/* Get it managed */
auto managedProfile = managedProfiles.get(model.name, null);
if (managedProfile is null)
{
return DatabaseResult(DatabaseError(DatabaseErrorCode.BucketNotFound,
"Profile not found"));
}

runTask({ managedProfile.refresh(); });
return NoDatabaseError;
}

package:

/**
Expand Down
Loading