v0.1.0 cf60d0e

common.sh RawHistoryFolder

1#!/usr/bin/env bash
2# Common functions and variables for all scripts
3
4# Get repository root
5get_repo_root() {
6    git rev-parse --show-toplevel
7}
8
9# Get current branch
10get_current_branch() {
11    git rev-parse --abbrev-ref HEAD
12}
13
14# Check if current branch is a feature branch
15# Returns 0 if valid, 1 if not
16check_feature_branch() {
17    local branch="$1"
18    if [[ ! "$branch" =~ ^[0-9]{3}- ]]; then
19        echo "ERROR: Not on a feature branch. Current branch: $branch"
20        echo "Feature branches should be named like: 001-feature-name"
21        return 1
22    fi
23    return 0
24}
25
26# Get feature directory path
27get_feature_dir() {
28    local repo_root="$1"
29    local branch="$2"
30    echo "$repo_root/specs/$branch"
31}
32
33# Get all standard paths for a feature
34# Usage: eval $(get_feature_paths)
35# Sets: REPO_ROOT, CURRENT_BRANCH, FEATURE_DIR, FEATURE_SPEC, IMPL_PLAN, TASKS
36get_feature_paths() {
37    local repo_root=$(get_repo_root)
38    local current_branch=$(get_current_branch)
39    local feature_dir=$(get_feature_dir "$repo_root" "$current_branch")
40    
41    echo "REPO_ROOT='$repo_root'"
42    echo "CURRENT_BRANCH='$current_branch'"
43    echo "FEATURE_DIR='$feature_dir'"
44    echo "FEATURE_SPEC='$feature_dir/spec.md'"
45    echo "IMPL_PLAN='$feature_dir/plan.md'"
46    echo "TASKS='$feature_dir/tasks.md'"
47    echo "RESEARCH='$feature_dir/research.md'"
48    echo "DATA_MODEL='$feature_dir/data-model.md'"
49    echo "QUICKSTART='$feature_dir/quickstart.md'"
50    echo "CONTRACTS_DIR='$feature_dir/contracts'"
51}
52
53# Check if a file exists and report
54check_file() {
55    local file="$1"
56    local description="$2"
57    if [[ -f "$file" ]]; then
58        echo "  ✓ $description"
59        return 0
60    else
61        echo "  ✗ $description"
62        return 1
63    fi
64}
65
66# Check if a directory exists and has files
67check_dir() {
68    local dir="$1"
69    local description="$2"
70    if [[ -d "$dir" ]] && [[ -n "$(ls -A "$dir" 2>/dev/null)" ]]; then
71        echo "  ✓ $description"
72        return 0
73    else
74        echo "  ✗ $description"
75        return 1
76    fi
77}

Keyboard shortcuts

Single-key shortcuts are on. ctrl k and esc work whatever this says.

ctrl k :
go to a section, branch, tag, file or repository
?
this list
j k
move the row cursor down / up
enter
open the row under the cursor; on Files, a directory opens or closes in place
↑ ↓ ← → home end
in the file tree (focus on a row): previous / next row, close / open a directory or go to its parent / first entry, first / last row. They never open a file
l h
on Files: open a directory or a file / close a directory or go up to its parent, then to the parent page. Elsewhere: into the side panel (on a merge request, its files) / back to the content; there j k move between its controls
g g G
first / last row
/
filter the list; on Files, find a file anywhere in the repository (esc clears, enter opens the best match)
b
switch branch or tag
g s g f g c g b g m g i g r g a
tabs: summary, files, commits, branches & tags, merge requests, issues, releases, actions (when available)
g h
home
w
wide mode: use the whole width of the screen, or not (remembered)
y
copy a permalink pinned to the commit
d u x
diff: split / unified / collapse or expand all
e E
diff: the whole file in view / every file, with the lines the hunks hide
n
merge request: next note in the diff
esc
close a dialog, leave a field

Branches 8

Tags 42

↑↓ moveenter openesc close