File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 4242 } ;
4343 } ) ;
4444
45+ packages = eachSystem (
46+ system :
47+ let
48+ pkgs = import nixpkgs { inherit system ; } ;
49+ in
50+ {
51+ git-safe-sync = pkgs . callPackage ./packages/git-safe-sync.nix { } ;
52+ }
53+ ) ;
54+
4555 devShells = eachSystem (
4656 system :
4757 let
Original file line number Diff line number Diff line change 1+ {
2+ writeShellApplication ,
3+ git ,
4+ coreutils ,
5+ } :
6+
7+ writeShellApplication {
8+ name = "git-safe-sync" ;
9+ runtimeInputs = [
10+ git
11+ coreutils
12+ ] ;
13+ text = ''
14+ set -euo pipefail
15+
16+ if [ "$#" -lt 2 ]; then
17+ echo "Usage: git-safe-sync <repo_url> <target_dir> [clone flags...]" >&2
18+ exit 1
19+ fi
20+
21+ REPO_URL="$1"
22+ TARGET_DIR="$2"
23+ shift 2
24+
25+ if [ ! -d "$TARGET_DIR" ]; then
26+ # Pass any extra flags (like --depth 1) to git clone
27+ git clone "$@" "$REPO_URL" "$TARGET_DIR"
28+ cd "$TARGET_DIR"
29+ if ! git verify-commit HEAD; then
30+ echo "Initial clone failed signature verification. Deleting unsafe clone." >&2
31+ cd /
32+ rm -rf "$TARGET_DIR"
33+ exit 1
34+ fi
35+ else
36+ cd "$TARGET_DIR"
37+ git fetch origin
38+ BRANCH=$(git rev-parse --abbrev-ref HEAD)
39+ git merge --ff-only --verify-signatures origin/"$BRANCH"
40+ fi
41+ '' ;
42+ }
You can’t perform that action at this time.
0 commit comments