feat(db): update Repository model to add lastPushedAt, isFork, forkedFromRepoId fields
+ 17
- 0
app/services/gitServer/onPushEvent.ts
@@ -13,6 +13,16 @@ const makeOnPushEvent: ServiceMethodFactory<
   return ({ data, message }) => {
     message.write("\n");
     if (data.packType === GitServer.PackType.RECEIVE) {
+      const receiveBuffer = [] as string[];
+
+      message.stream.on("data", (chunk) => receiveBuffer.push(chunk));
+      message.stream.on("close", () => {
+        console.log(
+          "message.stream::data:",
+          Buffer.from(receiveBuffer.join("")).toString("utf-8")
+        );
+      });
+
       // client has done something like "git push"
       // it is uploading, we are receiving
       console.log("receive-pack");

new file
db/migrations/20220923221619_add_last_pushed_at_is_fork_and_forked_from_repo_id/migration.sql
@@ -0,0 +1,4 @@
+-- AlterTable
+ALTER TABLE "Repository" ADD COLUMN     "forkedFromRepoId" TEXT,
+ADD COLUMN     "isFork" BOOLEAN NOT NULL DEFAULT false,
+ADD COLUMN     "lastPushedAt" TIMESTAMP(3);

@@ -81,6 +81,7 @@ model Repository {
 
   createdAt DateTime @default(now())
   updatedAt DateTime @updatedAt
+  lastPushedAt DateTime?
 
   avatarUri        String?
   displayName      String?

...
@@ -88,6 +89,8 @@ model Repository {
   shortDescription String?
   visibility       ResourceVisibility @default(PRIVATE)
   websiteUrl       String?
+  isFork           Boolean @default(false)
+  forkedFromRepoId String?
 
   organization   Organization @relation("ManyRepositoriesToOneOrganization", fields: [organizationId], references: [id])
   organizationId String