Skip to content

Commit

Permalink
Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Vatsal Gupta committed Nov 23, 2024
1 parent 897f478 commit d553933
Show file tree
Hide file tree
Showing 6 changed files with 89 additions and 48 deletions.
6 changes: 5 additions & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@
"usernamehw.errorlens"
],
"settings": {
"[markdown]": {
"editor.defaultFormatter": "DavidAnson.vscode-markdownlint",
"editor.rulers": [80]
},
"[shellscript]": {
"editor.defaultFormatter": "foxundermoon.shell-format",
"editor.tabSize": 4,
Expand Down Expand Up @@ -59,7 +63,7 @@
},
"image": "mcr.microsoft.com/devcontainers/base:noble",
"mounts": [
"source=${localWorkspaceFolder:-.}/snippets,target=${containerWorkspaceFolder}/.vscode,type=bind,consistency=cached,readonly"
"source=${localWorkspaceFolder}/snippets,target=${containerWorkspaceFolder}/.vscode,type=bind,consistency=cached"
],
"postCreateCommand": "chmod +x ${containerWorkspaceFolder}/.devcontainer/postCreateScript.sh && ${containerWorkspaceFolder}/.devcontainer/postCreateScript.sh",
"runArgs": [
Expand Down
22 changes: 22 additions & 0 deletions .devcontainer/postCreateScript.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@
###################################################################################################
# Global Variables & Constants
###################################################################################################
readonly SNIPPETS_DIR="snippets"
readonly VSCODE_DIR=".vscode"
readonly SNIPPET_FILES_PATTERN="*.code-snippets"

readonly ALIAS_FILE_LINK="https://raw.githubusercontent.com/gvatsal60/Linux-Aliases/HEAD/install.sh"

Expand All @@ -46,3 +49,22 @@ else
echo "Error: curl is not installed. Unable to use Linux aliases"
exit 1
fi

# As bind mounts not supported in GitHub Codespaces
if [ -n "${CODESPACE_NAME}" ]; then
# Generate symlinks for snippet files
# Create the .vscode directory if it doesn't already exist.
mkdir -p "${VSCODE_DIR}"
# Unlink all symbolic links in the '.vscode' directory
find "${VSCODE_DIR}" -type l -name "${SNIPPET_FILES_PATTERN}" | while read -r file; do
unlink "${file}"
done
# Check if the 'snippets' directory exists
if [ -d "${SNIPPETS_DIR}" ]; then
# Find all .code-snippet files in the 'snippets' directory and create symbolic links
find "${SNIPPETS_DIR}" -type f -name "${SNIPPET_FILES_PATTERN}" | while read -r file; do
# Create a symbolic link in '.vscode' with the same base name
ln -s "$(realpath "${file}")" "${VSCODE_DIR}/$(basename "${file}")"
done
fi
fi
32 changes: 0 additions & 32 deletions .github/workflows/ShellCheck.yaml

This file was deleted.

37 changes: 37 additions & 0 deletions .github/workflows/shell-format.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Shell Format
on:
pull_request:
branches: ["*"]
push:
branches:
- master
permissions:
contents: write # Grant write permission only for contents (commit/push)
jobs:
shell-format:
name: Shell Format (shfmt)
runs-on: ubuntu-latest
defaults:
run:
shell: bash
steps:
- name: Checkout Code
uses: actions/checkout@v4
- name: Install shfmt
run: |
sudo apt-get install shfmt -y
- name: Format Shell Scripts
run: |
find . -type f -name "*.sh" -exec shfmt -w {} \;
- name: Commit and Push Changes
run: |
git diff --exit-code || (
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git add .
git commit -m "Format shell scripts with shfmt"
git push origin HEAD
)
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

2 changes: 0 additions & 2 deletions .markdownlint.yaml

This file was deleted.

38 changes: 25 additions & 13 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,25 +16,37 @@ Please follow these guidelines to ensure a smooth process.

### General Guidelines

- **Indentation**: Use 4 spaces for indentation in all code files. Avoid using tabs.
- **Line Length**: Limit lines to improve readability.
- **Naming Conventions**: Use meaningful variable and function names. Variables should be written in lowercase with underscores separating words (e.g., `my_variable`), while function names should use lowercase with underscores (e.g., `my_function`).
* **Indentation**: Use 4 spaces for indentation in all code files. Avoid using tabs.
* **Line Length**: Limit lines to improve readability.
* **Naming Conventions**: Use meaningful variable and function names.
Variables should be written in lowercase with underscores separating words
(e.g., `my_variable`), while function names should use lowercase
with underscores (e.g., `my_function`).

### Bash Scripts

- **Indentation**: Use 4 spaces for indentation. Ensure consistent indentation throughout the script.
- **POSIX Compliance**: Write scripts to be POSIX-compliant whenever possible to ensure compatibility across different Unix-like systems. Avoid using non-standard features or extensions specific to a particular shell.
- **Quoting**: Always quote variable expansions (e.g., `"${variable}"`) to prevent issues with spaces or special characters.
- **Shebang**: Use `#!/bin/sh` for POSIX-compliant scripts. If specific shell features are needed, document the specific shell requirement in the script header.
- **Function Definitions**: Define functions without `function` keyword (e.g., `my_function() { ... }`). Consistency is key.
- **Comments**: Use comments to explain complex logic or provide context. Keep comments concise and relevant.
- **Error Handling**: Include error handling for critical operations.
- **External Commands**: Prefer using built-in commands and utilities when possible. Minimize the use of external commands to improve script portability and performance.
* **Indentation**: Use 4 spaces for indentation.
Ensure consistent indentation throughout the script.
* **POSIX Compliance**: Write scripts to be POSIX-compliant whenever
possible to ensure compatibility across different Unix-like systems.
Avoid using non-standard features or extensions specific to a particular shell.
* **Quoting**: Always quote variable expansions (e.g., `"${variable}"`)
to prevent issues with spaces or special characters.
* **Shebang**: Use `#!/bin/sh` for POSIX-compliant scripts.
If specific shell features are needed, document the specific
shell requirement in the script header.
* **Function Definitions**: Define functions without `function` keyword
(e.g., `my_function() { ... }`). Consistency is key.
* **Comments**: Use comments to explain complex logic or provide context.
Keep comments concise and relevant.
* **Error Handling**: Include error handling for critical operations.
* **External Commands**: Prefer using built-in commands and utilities when possible.
Minimize the use of external commands to improve script portability and performance.

## Reporting Bugs

Please report bugs using the GitHub issue tracker. Include steps to reproduce the bug and
any relevant error messages.
Please report bugs using the GitHub issue tracker.
Include steps to reproduce the bug and any relevant error messages.

## Contact

Expand Down

0 comments on commit d553933

Please sign in to comment.