-
Notifications
You must be signed in to change notification settings - Fork 7
feat: Add BAT feature for syntax highlighting and Git integration #55
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
acfeb03
Initial plan
Copilot 33e9f6f
feat: add BAT feature with Ubuntu/Debian package installation
Copilot 2eee8fd
refactor: clean up bat install script output
Copilot 811c5c5
fix: remove autogenerated README and restructure bat testing
Copilot 0a3f1df
feat: update bat feature to install from GitHub releases instead of a…
Copilot 7e1b64d
feat(ci): improve BAT feature testing and clean up configuration
jsburckhardt File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,16 +1,16 @@ | ||
| ## Commit Messages. | ||
| # General Instructions | ||
|
|
||
| We follow conventional commit specification for commit messages. This means that each commit message should start with a type, followed by an optional scope, and then a description. The types we use are: | ||
| - Ensure any code you produce is correct. | ||
| - for commit messages use conventional commit format, e.g. `feat: add new feature`, `fix: correct a bug`, `docs: update documentation`, etc. https://www.conventionalcommits.org/en/v1.0.0/ | ||
|
|
||
| - **feat**: A new feature | ||
| - **fix**: A bug fix | ||
| - **docs**: Documentation only changes | ||
| - **style**: Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc) | ||
| - **refactor**: A code change that neither fixes a bug nor adds a feature | ||
| - **perf**: A code change that improves performance | ||
| - **test**: Adding missing or correcting existing tests | ||
| - **build**: Changes that affect the build system or external dependencies (example scopes: gulp, broccoli, npm) | ||
| - **ci**: Changes to our CI configuration files and scripts (example scopes: Travis, Circle, BrowserStack, SauceLabs) | ||
| - **chore**: Other changes that don't modify src or test files | ||
| ## New Feature Instructions | ||
|
|
||
| More details in here https://www.conventionalcommits.org/en/v1.0.0/ | ||
| When creating a new feature, follow these steps: | ||
| - Update the README.md to include the new feature in the list of features. | ||
| - Each feature should be implemented under src/feature-name. Include a devcontainer-feature.json and install.sh file. | ||
| - The install.sh file should install the package from the source repository. Not using a package manager like apt. | ||
| - Each feature should have a test under test/feature-name/test.sh | ||
| - Each feature should include a global test under test/_global/feature-name-specific-version.sh if a specific version can be installed. | ||
| - Update the ../../test/_global/all-tools.sh to validate the new feature is installed. | ||
| - Update the ../../test/_global/scenarios.json to include the new feature. | ||
| - include the feature in the workflows |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| Generate a Git commit message using the Conventional Commits format. Then, include three --trailer fields: | ||
|
|
||
| Assistant-model: The name of the AI model (e.g., GPT-4o) | ||
|
|
||
| LLM-Contrib: An estimated percentage of contribution from the AI (e.g., 60%) | ||
|
|
||
| Prompt: A brief human instruction or goal (e.g., "Refactor for readability") | ||
|
|
||
| Format the final output like this: | ||
|
|
||
| bash | ||
| Copy | ||
| Edit | ||
| git commit --message "type(scope): concise description" \ | ||
| --trailer "Assistant-model: GPT-4o" \ | ||
| --trailer "LLM-Contrib: 60%" \ | ||
| --trailer "Prompt: <short description of prompt>" | ||
| Use an appropriate Conventional Commit type (like feat, fix, refactor, docs, etc.) and optionally include a scope if relevant. |
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -27,6 +27,7 @@ jobs: | |
| - skopeo | ||
| - uv | ||
| - codex | ||
| - bat | ||
| baseImage: | ||
| - debian:latest | ||
| - ubuntu:latest | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| { | ||
| "name": "bat", | ||
| "id": "bat", | ||
| "version": "1.0.0", | ||
| "description": "A cat(1) clone with syntax highlighting and Git integration.", | ||
| "options": { | ||
| "version": { | ||
| "type": "string", | ||
| "default": "latest", | ||
| "description": "Version of bat to install from GitHub releases e.g. v0.22.0" | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,120 @@ | ||
| #!/usr/bin/env bash | ||
|
|
||
| # Variables | ||
| REPO_OWNER="sharkdp" | ||
| REPO_NAME="bat" | ||
| BINARY_NAME="bat" | ||
| BAT_VERSION="${VERSION:-"latest"}" | ||
| GITHUB_API_REPO_URL="https://api.github.com/repos/${REPO_OWNER}/${REPO_NAME}/releases" | ||
|
|
||
| set -e | ||
|
|
||
| if [ "$(id -u)" -ne 0 ]; then | ||
| echo -e 'Script must be run as root. Use sudo, su, or add "USER root" to your Dockerfile before running this script.' | ||
| exit 1 | ||
| fi | ||
|
|
||
| # Clean up | ||
| rm -rf /var/lib/apt/lists/* | ||
|
|
||
| # Checks if packages are installed and installs them if not | ||
| check_packages() { | ||
| if ! dpkg -s "$@" >/dev/null 2>&1; then | ||
| if [ "$(find /var/lib/apt/lists/* | wc -l)" = "0" ]; then | ||
| echo "Running apt-get update..." | ||
| apt-get update -y | ||
| fi | ||
| apt-get -y install --no-install-recommends "$@" | ||
| fi | ||
| } | ||
|
|
||
| # Make sure we have curl and jq | ||
| check_packages curl jq ca-certificates | ||
|
|
||
| # Function to get the latest version from GitHub API | ||
| get_latest_version() { | ||
| curl -s "${GITHUB_API_REPO_URL}/latest" | jq -r ".tag_name" | ||
| } | ||
|
|
||
| # Check if a version is passed as an argument | ||
| if [ -z "$BAT_VERSION" ] || [ "$BAT_VERSION" == "latest" ]; then | ||
| # No version provided, get the latest version | ||
| BAT_VERSION=$(get_latest_version) | ||
| echo "No version provided or 'latest' specified, installing the latest version: $BAT_VERSION" | ||
| else | ||
| echo "Installing version from environment variable: $BAT_VERSION" | ||
| fi | ||
|
|
||
| # Determine the OS and architecture | ||
| OS=$(uname -s | tr '[:upper:]' '[:lower:]') | ||
| ARCH=$(uname -m) | ||
|
|
||
| case "$ARCH" in | ||
| x86_64) | ||
| ARCH="x86_64" | ||
| ;; | ||
| i686) | ||
| ARCH="i686" | ||
| ;; | ||
| aarch64) | ||
| ARCH="aarch64" | ||
| ;; | ||
| armv7l) | ||
| ARCH="arm-unknown" | ||
| ;; | ||
| *) | ||
| echo "Unsupported architecture: $ARCH" | ||
| exit 1 | ||
| ;; | ||
| esac | ||
|
|
||
| case "$OS" in | ||
| linux) | ||
| OS="unknown-linux-gnu" | ||
| ;; | ||
| darwin) | ||
| OS="apple-darwin" | ||
| ;; | ||
| *) | ||
| echo "Unsupported OS: $OS" | ||
| exit 1 | ||
| ;; | ||
| esac | ||
|
|
||
| # Construct the download URL | ||
| DOWNLOAD_URL="https://github.com/${REPO_OWNER}/${REPO_NAME}/releases/download/${BAT_VERSION}/bat-${BAT_VERSION}-${ARCH}-${OS}.tar.gz" | ||
|
|
||
| # Create a temporary directory for the download | ||
| TMP_DIR=$(mktemp -d) | ||
| cd "$TMP_DIR" || exit | ||
|
|
||
| echo "Downloading bat from $DOWNLOAD_URL" | ||
| curl -sSL "$DOWNLOAD_URL" -o "bat.tar.gz" | ||
|
|
||
| # Extract the tarball | ||
| echo "Extracting bat..." | ||
| tar -xzf "bat.tar.gz" | ||
|
|
||
| # Find the extracted directory (it should match the archive name pattern) | ||
| EXTRACTED_DIR=$(find . -name "bat-${BAT_VERSION}-*" -type d | head -1) | ||
| if [ -z "$EXTRACTED_DIR" ]; then | ||
| echo "ERROR: Could not find extracted bat directory" | ||
| exit 1 | ||
| fi | ||
|
|
||
| # Move the binary to /usr/local/bin | ||
| echo "Installing bat..." | ||
| mv "${EXTRACTED_DIR}/bat" /usr/local/bin/ | ||
|
|
||
| # Cleanup | ||
| cd - || exit | ||
| rm -rf "$TMP_DIR" | ||
|
|
||
| # Clean up | ||
| rm -rf /var/lib/apt/lists/* | ||
|
|
||
| # Verify installation | ||
| echo "Verifying installation..." | ||
| bat --version | ||
|
|
||
| echo "Done!" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| #!/bin/bash | ||
|
|
||
| set -e | ||
| source dev-container-features-test-lib | ||
| check "bat with specific version" /bin/bash -c "bat --version | grep '0.25.0'" | ||
|
|
||
| reportResults |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
|
jsburckhardt marked this conversation as resolved.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| #!/bin/bash | ||
|
|
||
| set -e | ||
|
|
||
| source dev-container-features-test-lib | ||
| check "bat" bat -h | ||
| reportResults |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.