Skip to content

Commit 0c7ccf2

Browse files
committed
feat: added git tags
1 parent 490975d commit 0c7ccf2

File tree

4 files changed

+11
-9
lines changed

4 files changed

+11
-9
lines changed

web/scripts/gitInfo.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ const main = () => {
1919
let gitCommitHash = execSyncWrapper("git rev-parse HEAD");
2020
let gitCommitShortHash = execSyncWrapper("git rev-parse --short=7 HEAD");
2121
let gitBranch = execSyncWrapper("git rev-parse --abbrev-ref HEAD");
22+
let gitTags = execSyncWrapper("git tag --points-at HEAD --omit-empty | tr '\n' ',' | sed 's/,$//'");
2223
let clean =
2324
execSyncWrapper(`[ -z "$(git status --short | ggrep -v '^??')" ] && echo clean || echo dirty`) === "clean";
2425

@@ -27,14 +28,14 @@ const main = () => {
2728
gitCommitHash,
2829
gitCommitShortHash,
2930
gitBranch,
31+
gitTags,
3032
clean,
3133
};
3234

3335
const filePath = path.resolve("src", "generatedGitInfo.json");
3436
const fileContents = JSON.stringify(obj, null, 2);
3537

3638
fs.writeFileSync(filePath, fileContents);
37-
// console.log(`Wrote the following contents to ${filePath}\n${fileContents}`);
3839
};
3940

4041
main();

web/src/consts/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { version, gitCommitHash, gitCommitShortHash, gitBranch, clean } from "../generatedGitInfo.json";
1+
import { version, gitCommitHash, gitCommitShortHash, gitBranch, gitTags, clean } from "../generatedGitInfo.json";
22

33
export const ONE_BASIS_POINT = 10000n;
44

@@ -9,6 +9,7 @@ export const PNK_FAUCET_CONTRACT_ADDRESS = "0x05648Ee14941630a649082e0dA5cb80D29
99
export const IPFS_GATEWAY = process.env.REACT_APP_IPFS_GATEWAY || "https://cdn.kleros.link";
1010

1111
export const GIT_BRANCH = gitBranch;
12+
export const GIT_TAGS = gitTags;
1213
export const GIT_HASH = gitCommitShortHash;
1314
export const GIT_DIRTY = clean ? "" : "-dirty";
1415
export const GIT_URL = `https://github.com/kleros/kleros-v2/tree/${gitCommitHash}/web`;

web/src/hooks/queries/usePhase.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export const usePhase = () => {
88
return useQuery({
99
queryKey: [`Phase`],
1010
enabled: isEnabled,
11-
staleTime: 20 * 1000, // 20 seconds
11+
staleTime: Infinity,
1212
queryFn: async () => {
1313
if (!sortitionModule) return;
1414
return await sortitionModule.read.phase();

web/src/layout/Header/navbar/Debug.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React from "react";
22
import styled from "styled-components";
3-
import { GIT_BRANCH, GIT_DIRTY, GIT_HASH, GIT_URL, RELEASE_VERSION } from "../../../consts";
3+
import { GIT_BRANCH, GIT_DIRTY, GIT_HASH, GIT_TAGS, GIT_URL, RELEASE_VERSION } from "../../../consts";
44
import { usePhase } from "~src/hooks/queries/usePhase";
55

66
const Container = styled.div`
@@ -18,22 +18,22 @@ const Version = () => (
1818
v{RELEASE_VERSION}{" "}
1919
<a href={GIT_URL} target="_blank" rel="noreferrer">
2020
#{GIT_HASH}
21-
</a>{" "}
22-
{GIT_BRANCH}
23-
{GIT_DIRTY && " dirty"}
21+
</a>
22+
{GIT_BRANCH && GIT_BRANCH !== "HEAD" && ` ${GIT_BRANCH}`}
23+
{GIT_TAGS && ` ${GIT_TAGS}`}
24+
{GIT_DIRTY && ` dirty`}
2425
</label>
2526
);
2627

2728
const Phase = () => {
2829
const { data: phase } = usePhase();
29-
return <label>phase: {phase}</label>;
30+
return phase && <label>, phase: {phase}</label>;
3031
};
3132

3233
const Debug: React.FC = () => {
3334
return (
3435
<Container>
3536
<Version />
36-
<label>{", "}</label>
3737
<Phase />
3838
</Container>
3939
);

0 commit comments

Comments
 (0)