Display git commit info in the /about section. (#567)
This change detects the most recent git commit short hash and writes it to the `GIT_COMMIT_INFO` constant in `packages/cli/src/generated/git-commit.sh`, optionally appending the string "(local modifications)" if additional local changes after that commit are detected. If set, this string is displayed in the `/about` dialog as well as passed into the `/bug` template. Example: ``` > /about ╭───────────────────────────────────────────────────────────────────────────╮ │ │ │ About Gemini CLI │ │ │ │ CLI Version development │ │ Git Commit 43370ab (local modifications) │ │ Model gemini-2.5-pro-preview-05-06 │ │ Sandbox sandbox-exec (minimal) │ │ OS darwin v23.11.0 │ │ │ ╰───────────────────────────────────────────────────────────────────────────╯ ``` Additionally, this change updates `.gitignore` to ignore the generated files, `scripts/clean.sh` to remove them, and adds a `npm run generate` stage for this and any other generators we need to write.
This commit is contained in:
parent
f2f2ecf9d8
commit
27a773d5b2
|
@ -31,3 +31,6 @@ bundle
|
||||||
# Test report files
|
# Test report files
|
||||||
junit.xml
|
junit.xml
|
||||||
packages/*/coverage/
|
packages/*/coverage/
|
||||||
|
|
||||||
|
# Generated files
|
||||||
|
packages/cli/src/generated/
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
"packages/*"
|
"packages/*"
|
||||||
],
|
],
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
"generate": "scripts/generate-git-commit-info.sh",
|
||||||
"build": "scripts/build.sh",
|
"build": "scripts/build.sh",
|
||||||
"build:sandbox": "scripts/build_sandbox.sh",
|
"build:sandbox": "scripts/build_sandbox.sh",
|
||||||
"build:all": "npm run build && npm run build:sandbox",
|
"build:all": "npm run build && npm run build:sandbox",
|
||||||
|
@ -24,7 +25,7 @@
|
||||||
"auth:docker": "gcloud auth configure-docker us-west1-docker.pkg.dev",
|
"auth:docker": "gcloud auth configure-docker us-west1-docker.pkg.dev",
|
||||||
"auth": "npm run auth:npm && npm run auth:docker",
|
"auth": "npm run auth:npm && npm run auth:docker",
|
||||||
"prerelease:dev": "npm run prerelease:version --workspaces && npm run prerelease:deps --workspaces",
|
"prerelease:dev": "npm run prerelease:version --workspaces && npm run prerelease:deps --workspaces",
|
||||||
"bundle": "node_modules/.bin/esbuild packages/cli/index.ts --bundle --outfile=bundle/gemini.js --platform=node --format=esm --banner:js=\"import { createRequire } from 'module'; const require = createRequire(import.meta.url); globalThis.__filename = require('url').fileURLToPath(import.meta.url); globalThis.__dirname = require('path').dirname(globalThis.__filename);\" && bash scripts/copy_bundle_assets.sh"
|
"bundle": "npm run generate && node_modules/.bin/esbuild packages/cli/index.ts --bundle --outfile=bundle/gemini.js --platform=node --format=esm --banner:js=\"import { createRequire } from 'module'; const require = createRequire(import.meta.url); globalThis.__filename = require('url').fileURLToPath(import.meta.url); globalThis.__dirname = require('path').dirname(globalThis.__filename);\" && bash scripts/copy_bundle_assets.sh"
|
||||||
},
|
},
|
||||||
"bin": {
|
"bin": {
|
||||||
"gemini": "bundle/gemini.js"
|
"gemini": "bundle/gemini.js"
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { Box, Text } from 'ink';
|
import { Box, Text } from 'ink';
|
||||||
import { Colors } from '../colors.js';
|
import { Colors } from '../colors.js';
|
||||||
|
import { GIT_COMMIT_INFO } from '../../generated/git-commit.js';
|
||||||
|
|
||||||
interface AboutBoxProps {
|
interface AboutBoxProps {
|
||||||
cliVersion: string;
|
cliVersion: string;
|
||||||
|
@ -44,6 +45,18 @@ export const AboutBox: React.FC<AboutBoxProps> = ({
|
||||||
<Text>{cliVersion}</Text>
|
<Text>{cliVersion}</Text>
|
||||||
</Box>
|
</Box>
|
||||||
</Box>
|
</Box>
|
||||||
|
{GIT_COMMIT_INFO && !['N/A'].includes(GIT_COMMIT_INFO) && (
|
||||||
|
<Box flexDirection="row">
|
||||||
|
<Box width="35%">
|
||||||
|
<Text bold color={Colors.LightBlue}>
|
||||||
|
Git Commit
|
||||||
|
</Text>
|
||||||
|
</Box>
|
||||||
|
<Box>
|
||||||
|
<Text>{GIT_COMMIT_INFO}</Text>
|
||||||
|
</Box>
|
||||||
|
</Box>
|
||||||
|
)}
|
||||||
<Box flexDirection="row">
|
<Box flexDirection="row">
|
||||||
<Box width="35%">
|
<Box width="35%">
|
||||||
<Text bold color={Colors.LightBlue}>
|
<Text bold color={Colors.LightBlue}>
|
||||||
|
|
|
@ -31,6 +31,7 @@ import { MessageType } from '../types.js';
|
||||||
import { type Config } from '@gemini-code/server';
|
import { type Config } from '@gemini-code/server';
|
||||||
|
|
||||||
import * as ShowMemoryCommandModule from './useShowMemoryCommand.js';
|
import * as ShowMemoryCommandModule from './useShowMemoryCommand.js';
|
||||||
|
import { GIT_COMMIT_INFO } from '../../generated/git-commit.js';
|
||||||
|
|
||||||
vi.mock('./useShowMemoryCommand.js', () => ({
|
vi.mock('./useShowMemoryCommand.js', () => ({
|
||||||
SHOW_MEMORY_COMMAND_NAME: '/memory show',
|
SHOW_MEMORY_COMMAND_NAME: '/memory show',
|
||||||
|
@ -244,6 +245,7 @@ Add any other context about the problem here.
|
||||||
|
|
||||||
## Diagnostic Information
|
## Diagnostic Information
|
||||||
* **CLI Version:** ${cliVersion}
|
* **CLI Version:** ${cliVersion}
|
||||||
|
* **Git Commit:** ${GIT_COMMIT_INFO}
|
||||||
* **Operating System:** ${osVersion}
|
* **Operating System:** ${osVersion}
|
||||||
* **Sandbox Environment:** ${sandboxEnvStr}
|
* **Sandbox Environment:** ${sandboxEnvStr}
|
||||||
* **Model Version:** ${modelVersion}
|
* **Model Version:** ${modelVersion}
|
||||||
|
|
|
@ -11,6 +11,7 @@ import { UseHistoryManagerReturn } from './useHistoryManager.js';
|
||||||
import { Config } from '@gemini-code/server';
|
import { Config } from '@gemini-code/server';
|
||||||
import { Message, MessageType, HistoryItemWithoutId } from '../types.js';
|
import { Message, MessageType, HistoryItemWithoutId } from '../types.js';
|
||||||
import { createShowMemoryAction } from './useShowMemoryCommand.js';
|
import { createShowMemoryAction } from './useShowMemoryCommand.js';
|
||||||
|
import { GIT_COMMIT_INFO } from '../../generated/git-commit.js';
|
||||||
|
|
||||||
export interface SlashCommandActionReturn {
|
export interface SlashCommandActionReturn {
|
||||||
shouldScheduleTool?: boolean;
|
shouldScheduleTool?: boolean;
|
||||||
|
@ -215,6 +216,7 @@ Add any other context about the problem here.
|
||||||
|
|
||||||
## Diagnostic Information
|
## Diagnostic Information
|
||||||
* **CLI Version:** ${cliVersion}
|
* **CLI Version:** ${cliVersion}
|
||||||
|
* **Git Commit:** ${GIT_COMMIT_INFO}
|
||||||
* **Operating System:** ${osVersion}
|
* **Operating System:** ${osVersion}
|
||||||
* **Sandbox Environment:** ${sandboxEnv}
|
* **Sandbox Environment:** ${sandboxEnv}
|
||||||
* **Model Version:** ${modelVersion}
|
* **Model Version:** ${modelVersion}
|
||||||
|
|
|
@ -4,9 +4,6 @@
|
||||||
"outDir": "dist",
|
"outDir": "dist",
|
||||||
"jsx": "react-jsx",
|
"jsx": "react-jsx",
|
||||||
"lib": ["DOM", "DOM.Iterable", "ES2020"],
|
"lib": ["DOM", "DOM.Iterable", "ES2020"],
|
||||||
"paths": {
|
|
||||||
"@gemini-code/*": ["./packages/*"]
|
|
||||||
},
|
|
||||||
"types": ["node", "vitest/globals"]
|
"types": ["node", "vitest/globals"]
|
||||||
},
|
},
|
||||||
"include": ["index.ts", "src/**/*.ts", "src/**/*.tsx", "src/**/*.json"],
|
"include": ["index.ts", "src/**/*.ts", "src/**/*.tsx", "src/**/*.json"],
|
||||||
|
|
|
@ -17,4 +17,5 @@ set -euo pipefail
|
||||||
|
|
||||||
# remove npm install/build artifacts
|
# remove npm install/build artifacts
|
||||||
rm -rf node_modules
|
rm -rf node_modules
|
||||||
|
rm -rf packages/cli/src/generated/
|
||||||
npm run clean --workspaces
|
npm run clean --workspaces
|
||||||
|
|
|
@ -0,0 +1,44 @@
|
||||||
|
#!/bin/bash
|
||||||
|
# Copyright 2025 Google LLC
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
GENERATED_DIR="packages/cli/src/generated"
|
||||||
|
GIT_COMMIT_FILE="$GENERATED_DIR/git-commit.ts"
|
||||||
|
GIT_COMMIT_INFO="N/A"
|
||||||
|
|
||||||
|
mkdir -p "$GENERATED_DIR"
|
||||||
|
|
||||||
|
if command -v git &> /dev/null && git rev-parse --is-inside-work-tree &> /dev/null; then
|
||||||
|
GIT_HASH=$(git rev-parse --short HEAD 2>/dev/null || echo "")
|
||||||
|
if [ -n "$GIT_HASH" ]; then
|
||||||
|
GIT_COMMIT_INFO="$GIT_HASH"
|
||||||
|
if [ -n "$(git status --porcelain 2>/dev/null)" ]; then
|
||||||
|
GIT_COMMIT_INFO="$GIT_HASH (local modifications)"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
cat <<EOL > "$GIT_COMMIT_FILE"
|
||||||
|
/**
|
||||||
|
* @license
|
||||||
|
* Copyright $(date +%Y) Google LLC
|
||||||
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
// This file is auto-generated by the build script (scripts/build.sh)
|
||||||
|
// Do not edit this file manually.
|
||||||
|
export const GIT_COMMIT_INFO = '$GIT_COMMIT_INFO';
|
||||||
|
EOL
|
Loading…
Reference in New Issue