Skip to content

Commit 4eed94a

Browse files
authored
expose git-commit from bundle (app-sre#79)
1 parent 9c99c42 commit 4eed94a

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

src/db.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ export type Bundle = {
2525
resourcefiles: im.Map<string, Resourcefile>;
2626
schema: any[];
2727
fileHash: string;
28+
gitCommit: string;
2829
};
2930

3031
const getRefPath = (ref: string): string => /^[^$]*/.exec(ref)[0];
@@ -64,6 +65,7 @@ const parseBundle = (contents: string) : Bundle => {
6465
datafiles: parseDatafiles(parsedContents.data),
6566
resourcefiles: parseResourcefiles(parsedContents.resources),
6667
fileHash: hashDatafile(contents),
68+
gitCommit: parsedContents['git_commit'],
6769
schema: parsedContents.graphql,
6870
} as Bundle;
6971
};
@@ -141,6 +143,7 @@ export const bundleFromEnvironment = async() => {
141143
resourcefiles: im.Map<string, Resourcefile>(),
142144
schema: {},
143145
fileHash: '',
146+
gitCommit: '',
144147
} as Bundle;
145148
}
146149
};

src/server.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,11 @@ export const appFromBundle = async (bundle: Promise<db.Bundle>) => {
137137
res.send(hash);
138138
});
139139

140+
app.get('/git-commit', (req: express.Request, res: express.Response) => {
141+
const git_commit = req.app.get('bundle').gitCommit;
142+
res.send(git_commit);
143+
});
144+
140145
app.get('/metrics', (req: express.Request, res: express.Response) => {
141146
res.send(promClient.register.metrics());
142147
});

0 commit comments

Comments
 (0)