Skip to content

Commit 1fe13e1

Browse files
committed
Update after merge
1 parent d1184a1 commit 1fe13e1

File tree

6 files changed

+28
-2
lines changed

6 files changed

+28
-2
lines changed

integrations/github/src/tasks.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ export async function handleImportDispatchForSpaces(
5050
context: GithubRuntimeContext,
5151
payload: IntegrationTaskImportSpaces['payload']
5252
): Promise<number | undefined> {
53-
const { configQuery, page, standaloneRef } = payload;
53+
const { configQuery, page, standaloneRef, eventTimestamp } = payload;
5454

5555
logger.debug(`handling import dispatch for spaces with payload: ${JSON.stringify(payload)}`);
5656

@@ -92,6 +92,7 @@ export async function handleImportDispatchForSpaces(
9292
ref: standaloneRef,
9393
}
9494
: undefined,
95+
eventTimestamp,
9596
});
9697
} catch (error) {
9798
logger.error(

integrations/github/src/types.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,13 @@ export type IntegrationTaskImportSpaces = BaseIntegrationTask<
9393
configQuery: string;
9494
page?: string;
9595
standaloneRef?: string;
96+
/**
97+
* The timestamp of the event that triggers the export.
98+
*
99+
* This is to help ensures that Git sync import and export operations are executed
100+
* in the same order on GitBook and on the remote repository.
101+
*/
102+
eventTimestamp?: Date;
96103
}
97104
>;
98105

integrations/github/src/webhooks.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,9 @@ export async function handlePushEvent(
6565

6666
const total = await handleImportDispatchForSpaces(context, {
6767
configQuery: queryKey,
68+
eventTimestamp: payload.head_commit?.timestamp
69+
? new Date(payload.head_commit?.timestamp)
70+
: undefined,
6871
});
6972

7073
logger.debug(`${total} space configurations are affected`);

integrations/gitlab/src/tasks.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ export async function handleImportDispatchForSpaces(
5050
context: GitLabRuntimeContext,
5151
payload: IntegrationTaskImportSpaces['payload']
5252
): Promise<number | undefined> {
53-
const { configQuery, page, standaloneRef } = payload;
53+
const { configQuery, page, standaloneRef, eventTimestamp } = payload;
5454

5555
logger.debug(`handling import dispatch for spaces with payload: ${JSON.stringify(payload)}`);
5656

@@ -92,6 +92,7 @@ export async function handleImportDispatchForSpaces(
9292
ref: standaloneRef,
9393
}
9494
: undefined,
95+
eventTimestamp,
9596
});
9697
} catch (error) {
9798
logger.error(

integrations/gitlab/src/types.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,13 @@ export type IntegrationTaskImportSpaces = BaseIntegrationTask<
8787
configQuery: string;
8888
page?: string;
8989
standaloneRef?: string;
90+
/**
91+
* The timestamp of the event that triggers the export.
92+
*
93+
* This is to help ensures that Git sync import and export operations are executed
94+
* in the same order on GitBook and on the remote repository.
95+
*/
96+
eventTimestamp?: Date;
9097
}
9198
>;
9299

integrations/gitlab/src/webhooks.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,15 @@ export async function handlePushEvent(context: GitLabRuntimeContext, payload: Gi
103103

104104
const queryKey = computeConfigQueryKey(gitlabProjectId, gitlabRef);
105105

106+
// Gitlab push events do not include a head_commit property so we need to get it from
107+
// the commits attribute which should contains the newest 20 commits:
108+
// https://docs.gitlab.com/ee/user/project/integrations/webhook_events.html#push-events
109+
const headCommitSha = payload.after;
110+
const headCommit = payload.commits.find((commit) => commit.id === headCommitSha);
111+
106112
const total = await handleImportDispatchForSpaces(context, {
107113
configQuery: queryKey,
114+
eventTimestamp: headCommit ? new Date(headCommit.timestamp) : undefined,
108115
});
109116

110117
logger.debug(`${total} space configurations are affected`);

0 commit comments

Comments
 (0)