~jan0sch/smederee
Showing details for patch 3f8a607218b82232b2b846a93d552cab220020fa.
diff -rN -u old-smederee/modules/hub/src/it/scala/de/smederee/hub/Generators.scala new-smederee/modules/hub/src/it/scala/de/smederee/hub/Generators.scala --- old-smederee/modules/hub/src/it/scala/de/smederee/hub/Generators.scala 2025-02-02 12:08:40.342761109 +0000 +++ new-smederee/modules/hub/src/it/scala/de/smederee/hub/Generators.scala 2025-02-02 12:08:40.342761109 +0000 @@ -170,12 +170,15 @@ name <- genValidUsername } yield VcsRepositoryOwner(uid, name) + val genValidVcsType = Gen.oneOf(VcsType.values.toList) + val genValidVcsRepository: Gen[VcsRepository] = for { name <- genValidVcsRepositoryName owner <- genValidVcsRepositoryOwner isPrivate <- Gen.oneOf(List(false, true)) description <- Gen.alphaNumStr.map(VcsRepositoryDescription.from) - } yield VcsRepository(name, owner, isPrivate, description, None) + vcsType <- genValidVcsType + } yield VcsRepository(name, owner, isPrivate, description, vcsType, None) val genValidVcsRepositories: Gen[List[VcsRepository]] = Gen.nonEmptyListOf(genValidVcsRepository) diff -rN -u old-smederee/modules/hub/src/main/resources/db/migration/V2__repository_tables.sql new-smederee/modules/hub/src/main/resources/db/migration/V2__repository_tables.sql --- old-smederee/modules/hub/src/main/resources/db/migration/V2__repository_tables.sql 2025-02-02 12:08:40.342761109 +0000 +++ new-smederee/modules/hub/src/main/resources/db/migration/V2__repository_tables.sql 2025-02-02 12:08:40.342761109 +0000 @@ -5,6 +5,7 @@ "owner" UUID NOT NULL, "is_private" BOOLEAN NOT NULL DEFAULT FALSE, "description" CHARACTER VARYING(254), + "vcs_type" CHARACTER VARYING(16) NOT NULL, "website" TEXT, "created_at" TIMESTAMP WITH TIME ZONE NOT NULL, "updated_at" TIMESTAMP WITH TIME ZONE NOT NULL, @@ -22,6 +23,7 @@ COMMENT ON COLUMN "repositories"."owner" IS 'The unique ID of the user account that owns the repository.'; COMMENT ON COLUMN "repositories"."is_private" IS 'A flag indicating if this repository is private i.e. only visible / accessible for accounts with appropriate permissions.'; COMMENT ON COLUMN "repositories"."description" IS 'An optional short text description of the repository.'; +COMMENT ON COLUMN "repositories"."vcs_type" IS 'The type of the underlying DVCS that manages the repository.'; COMMENT ON COLUMN "repositories"."website" IS 'An optional uri pointing to a website related to the repository / project.'; COMMENT ON COLUMN "repositories"."created_at" IS 'The timestamp of when the repository was created.'; COMMENT ON COLUMN "repositories"."updated_at" IS 'A timestamp when the repository was last changed.'; diff -rN -u old-smederee/modules/hub/src/main/scala/de/smederee/hub/DoobieVcsMetadataRepository.scala new-smederee/modules/hub/src/main/scala/de/smederee/hub/DoobieVcsMetadataRepository.scala --- old-smederee/modules/hub/src/main/scala/de/smederee/hub/DoobieVcsMetadataRepository.scala 2025-02-02 12:08:40.342761109 +0000 +++ new-smederee/modules/hub/src/main/scala/de/smederee/hub/DoobieVcsMetadataRepository.scala 2025-02-02 12:08:40.342761109 +0000 @@ -33,15 +33,16 @@ given Meta[VcsRepositoryName] = Meta[String].timap(VcsRepositoryName.apply)(_.toString) given Meta[VcsRepositoryDescription] = Meta[String].timap(VcsRepositoryDescription.apply)(_.toString) + given Meta[VcsType] = Meta[String].timap(VcsType.valueOf)(_.toString) given Meta[Uri] = Meta[String].timap(Uri.unsafeFromString)(_.toString) given Meta[UserId] = Meta[UUID].timap(UserId.apply)(_.toUUID) given Meta[Username] = Meta[String].timap(Username.apply)(_.toString) private val selectRepositoryColumns = - fr"""SELECT "repos".name AS name, "accounts".uid AS owner_id, "accounts".name AS owner_name, "repos".is_private AS is_private, "repos".description AS description, "repos".website AS website FROM "repositories" AS "repos" JOIN "accounts" ON "repos".owner = "accounts".uid""" + fr"""SELECT "repos".name AS name, "accounts".uid AS owner_id, "accounts".name AS owner_name, "repos".is_private AS is_private, "repos".description AS description, "repos".vcs_type AS vcs_type, "repos".website AS website FROM "repositories" AS "repos" JOIN "accounts" ON "repos".owner = "accounts".uid""" override def createVcsRepository(repository: VcsRepository): F[Int] = - sql"""INSERT INTO "repositories" (name, owner, is_private, description, website, created_at, updated_at) VALUES (${repository.name}, ${repository.owner.uid}, ${repository.isPrivate}, ${repository.description}, ${repository.website}, NOW(), NOW())""".update.run + sql"""INSERT INTO "repositories" (name, owner, is_private, description, vcs_type, website, created_at, updated_at) VALUES (${repository.name}, ${repository.owner.uid}, ${repository.isPrivate}, ${repository.description}, ${repository.vcsType}, ${repository.website}, NOW(), NOW())""".update.run .transact(tx) override def findVcsRepository( diff -rN -u old-smederee/modules/hub/src/main/scala/de/smederee/hub/VcsRepositoryRoutes.scala new-smederee/modules/hub/src/main/scala/de/smederee/hub/VcsRepositoryRoutes.scala --- old-smederee/modules/hub/src/main/scala/de/smederee/hub/VcsRepositoryRoutes.scala 2025-02-02 12:08:40.342761109 +0000 +++ new-smederee/modules/hub/src/main/scala/de/smederee/hub/VcsRepositoryRoutes.scala 2025-02-02 12:08:40.342761109 +0000 @@ -569,6 +569,7 @@ user.toVcsRepositoryOwner, newVcsRepository.isPrivate, newVcsRepository.description, + VcsType.Darcs, newVcsRepository.website ) output <- darcs.initialize(directory)(newVcsRepository.name.toString)(Chain.empty) diff -rN -u old-smederee/modules/hub/src/main/scala/de/smederee/hub/VcsRepository.scala new-smederee/modules/hub/src/main/scala/de/smederee/hub/VcsRepository.scala --- old-smederee/modules/hub/src/main/scala/de/smederee/hub/VcsRepository.scala 2025-02-02 12:08:40.342761109 +0000 +++ new-smederee/modules/hub/src/main/scala/de/smederee/hub/VcsRepository.scala 2025-02-02 12:08:40.342761109 +0000 @@ -24,6 +24,15 @@ import scala.util.matching.Regex +/** The types of version control software that we support. + */ +enum VcsType { + + /** The darcs DVCS. + */ + case Darcs +} + opaque type VcsRepositoryDescription = String object VcsRepositoryDescription { val MaximumLength: Int = 254 @@ -145,6 +154,8 @@ * appropriate permissions. * @param description * An optional short text description of the repository. + * @param vcsType + * The type of the underlying DVCS that manages the repository. * @param website * An optional uri pointing to a website related to the repository / project. */ @@ -153,6 +164,7 @@ owner: VcsRepositoryOwner, isPrivate: Boolean, description: Option[VcsRepositoryDescription], + vcsType: VcsType, website: Option[Uri] ) diff -rN -u old-smederee/modules/hub/src/main/twirl/de/smederee/hub/views/showRepositories.scala.html new-smederee/modules/hub/src/main/twirl/de/smederee/hub/views/showRepositories.scala.html --- old-smederee/modules/hub/src/main/twirl/de/smederee/hub/views/showRepositories.scala.html 2025-02-02 12:08:40.342761109 +0000 +++ new-smederee/modules/hub/src/main/twirl/de/smederee/hub/views/showRepositories.scala.html 2025-02-02 12:08:40.342761109 +0000 @@ -4,6 +4,13 @@ <div class="content"> <div class="pure-g"> <div class="pure-u-1-1 pure-u-md-1-1"> + <div class="l-box-left-right"> + <h2>~@repositoriesOwner</h2> + </div> + </div> + </div> + <div class="pure-g"> + <div class="pure-u-1-1 pure-u-md-1-1"> <div class="l-box"> @if(listing.nonEmpty) { <table class="pure-table pure-table-horizontal"> diff -rN -u old-smederee/modules/hub/src/main/twirl/de/smederee/hub/views/showRepositoryOverview.scala.html new-smederee/modules/hub/src/main/twirl/de/smederee/hub/views/showRepositoryOverview.scala.html --- old-smederee/modules/hub/src/main/twirl/de/smederee/hub/views/showRepositoryOverview.scala.html 2025-02-02 12:08:40.342761109 +0000 +++ new-smederee/modules/hub/src/main/twirl/de/smederee/hub/views/showRepositoryOverview.scala.html 2025-02-02 12:08:40.342761109 +0000 @@ -39,12 +39,18 @@ <dd> <form class="pure-form"> <fieldset> - <input class="pure-input-1" type="text" value="@{actionBaseUri}.darcs" readonly="readonly"/> + <input class="pure-input-1" id="clone-readonly" type="text" value="darcs clone @{actionBaseUri}.darcs" readonly="readonly"/> </fieldset> </form> </dd> <dt>@Messages("repository.overview.clone.read-write")</dt> - <dd>TODO</dd> + <dd> + <form class="pure-form"> + <fieldset> + <input class="pure-input-1" id="clone-readonly" type="text" value="NOT YET IMPLEMENTED!" readonly="readonly"/> + </fieldset> + </form> + </dd> </dl> </div> </div> diff -rN -u old-smederee/modules/hub/src/test/scala/de/smederee/hub/Generators.scala new-smederee/modules/hub/src/test/scala/de/smederee/hub/Generators.scala --- old-smederee/modules/hub/src/test/scala/de/smederee/hub/Generators.scala 2025-02-02 12:08:40.342761109 +0000 +++ new-smederee/modules/hub/src/test/scala/de/smederee/hub/Generators.scala 2025-02-02 12:08:40.342761109 +0000 @@ -170,12 +170,15 @@ name <- genValidUsername } yield VcsRepositoryOwner(uid, name) + val genValidVcsType = Gen.oneOf(VcsType.values.toList) + val genValidVcsRepository: Gen[VcsRepository] = for { name <- genValidVcsRepositoryName owner <- genValidVcsRepositoryOwner isPrivate <- Gen.oneOf(List(false, true)) description <- Gen.alphaNumStr.map(VcsRepositoryDescription.from) - } yield VcsRepository(name, owner, isPrivate, description, None) + vcsType <- genValidVcsType + } yield VcsRepository(name, owner, isPrivate, description, vcsType, None) val genValidVcsRepositories: Gen[List[VcsRepository]] = Gen.nonEmptyListOf(genValidVcsRepository)