Commit Graph

766 Commits

Author SHA1 Message Date
Tim Hockin 9318041657 Better logging around hooks
This also returns stderr distinct from stdout.
2023-05-24 10:52:21 -07:00
Tim Hockin ed170912c9 Move main.go to root of repo
This allows `go install k8s.io/git-sync` which I like.
2023-05-22 08:40:24 -07:00
Tim Hockin f3565bf410 Move flag defs into main() 2023-05-16 16:11:03 -07:00
Tim Hockin 8ee0f7ef9a Update README and other docs 2023-05-16 16:10:50 -07:00
Tim Hockin e15c7a9695 Tighten up cleanup to be called once per loop 2023-05-16 16:10:23 -07:00
Tim Hockin 451ac415ea Add a unit test for touch() 2023-05-16 16:10:07 -07:00
Tim Hockin c3a49e9d46 Get rid of "must not start with ." logic
It serves very little purpose and isn't even correct as-is.
2023-05-14 11:11:24 -07:00
Tim Hockin ff1a913bab Reorganize flag definitions 2023-05-14 11:10:17 -07:00
Kubernetes Prow Robot e1c7c63987
Merge pull request #715 from sviscaino/add-keep-worktrees-option
Add --stale-worktree-timeout option
2023-05-14 11:07:27 -07:00
Sacha Viscaino 622ced3864 Add --stale-worktree-timeout option 2023-05-14 00:28:29 +01:00
Tim Hockin 4b7b68d34c EOL the `--change-permissions` flag
This is a breaking change.  The `--change-permissions` flag was too
coarse (e.g. changed directories and files alike) and not expressive (no
way to say "g+w").

I doubt if anyone was using it, and if they were, the new
`--group-write` is almost certainly what they want.
2023-05-11 09:42:20 -07:00
Tim Hockin 58cab771fc e2e: Fix weirdly quoted strings
I have been meaning to do this forever.
2023-05-11 09:42:05 -07:00
Tim Hockin ca36eb5733 Sort deprecated flag vars 2023-05-08 15:51:36 -07:00
Tim Hockin a16175f4e3 Rename deprecated flag vars 2023-05-08 15:51:36 -07:00
Tim Hockin 12c1ece35f Support in-place updates from v3
A few small accomodations and we can clean up properly.
2023-05-08 15:51:23 -07:00
Tim Hockin 7eaba7605a Rename metric variables 2023-05-08 15:51:16 -07:00
Tim Hockin d197740d85 Exercise the git "dubious ownership" path
To do this, we run the e2e test as a different user.  To do that, we
need git-sync to make sure that everything is group accessible.  To
clean up after the test, we need everything to be group writable.  To do
that, we add a new flag: `--group-write`.
2023-05-07 10:29:39 -07:00
Tim Hockin 45c7b89674 V4: prevent git's 'dubious ownership' error 2023-05-07 10:29:39 -07:00
Tim Hockin f287d63171 Fetch just once per run and when hash changes 2023-05-07 10:29:31 -07:00
Kubernetes Prow Robot edcf77bde2
Merge pull request #730 from thockin/v4_go_1_20
Update to go 1.20
2023-05-05 14:51:16 -07:00
Tim Hockin e033732c3c Use absPath type for link and touchfile 2023-05-05 13:30:11 -07:00
Tim Hockin 6cd8b5a1cf Add an absPath type and use it for git.root 2023-05-05 13:30:11 -07:00
Tim Hockin fd0ec2131b
Update to go 1.20 2023-05-05 13:27:36 -07:00
Tim Hockin 64ed3bb5a7 Capture and simplify a git.Run() method 2023-05-04 17:42:08 -07:00
Tim Hockin 0bd5f19ac0 Make flag defs easier to read 2023-05-04 17:39:31 -07:00
Tim Hockin 7e6b429362 Make all env var names GITSYNC_FOO
Still support GIT_SYNC_FOO for compat.
2023-05-04 08:45:25 -07:00
Tim Hockin 5cc7160985 Clean up all old worktrees 2023-05-04 08:45:13 -07:00
Tim Hockin 10af97f51d Move worktrees to .worktrees/*
This will make it easier to enumerate old worktrees and do better
cleanup.
2023-04-29 10:51:13 -07:00
Tim Hockin 988bfb7a01 e2e: handle log capture automatically
Same as test_git.sh
2023-04-29 10:44:07 -07:00
Tim Hockin 7370e9dc6f Back-compat for --v usage 2023-04-29 10:42:52 -07:00
Tim Hockin 707d527e03 Add a doc about changing from v3 to v4 2023-04-29 10:42:26 -07:00
Tim Hockin e84a4cb4fd Make --webhook-success-status=0 the same as -1 2023-04-29 10:40:53 -07:00
Tim Hockin 20ed7df894 Makefile: set GOOS,GOARCH defaults to kill warning 2023-04-29 10:39:07 -07:00
Tim Hockin cbedbc0ca5 Add test for repo size and change default GC
--git-gc=always seems to be the right tradeoff.
2023-04-28 14:07:54 -07:00
Tim Hockin dc56d5d6bf Tidy up log levels - logs read better now 2023-04-28 14:07:42 -07:00
Tim Hockin f6678b98e8 Change the default depth to 1
For most users this is functionally equivalent and more efficient.  For
users who really need the full history, set this to 0.
2023-04-28 14:07:35 -07:00
Tim Hockin 76e91a2304 Fine tune git command verbosity flags 2023-04-28 14:07:18 -07:00
Tim Hockin 07df59eccc Move code (no edits), document methods 2023-04-28 14:07:05 -07:00
Tim Hockin ee6664748f Total overhaul of sync loop
The previous (v3) sync loop betrays my lack of understanding about git.
It tried to codify my archaic mental model (e.g. --branch and --rev
being disting things) and was ultimately a patchwork of corner-cases
evolved over a few years.

This commit is less of a "diff" and more of a "rewrite".

The new logic is simpler and more efficient.  It does not `git clone`
ever.  It does not differentiate the first sync from subsequent syncs.
It uses `git fetch` to get the exact SHA and then makes a worktree from
that.

The new `--ref` flag replaces both `--rev` and `--branch`, though it
will use those if specified.  In fact, almost all of the e2e tests
passed without change - using --ref and --branch!

I will follow this commit up with more cleanups and e2es.
2023-04-21 17:25:25 -07:00
Tim Hockin bb0128b883 Don't ignore invalid env vars 2023-04-06 17:46:19 -07:00
Tim Hockin b36c6851a2 Use a private gitconfig file
This was changing my own ~/.gitconfig whenever run by hand outside of a
container.  Oops.
2023-04-06 17:46:05 -07:00
Tim Hockin 026c6814c8 Add execution time to pkg/cmd runs 2023-04-06 17:45:54 -07:00
Tim Hockin f95f3c24f7 e2e: print failing line 2023-04-06 17:45:36 -07:00
Tim Hockin f4d067c987 e2e: compare numbers numerically, not lexically
Thanks, bash, for supporting `<` and `>` and making them NOT mean the
obvious thing.

This shows up when you set RUNS=10:
`[[ 2 < 10 ]]` is false
`(( 2 < 10 ))` is true
2023-04-06 17:45:26 -07:00
Tim Hockin c1b8617385 e2e: s/REV/SHA 2023-04-06 17:45:16 -07:00
Kubernetes Prow Robot cadd8b06e6
Merge pull request #684 from saschagrunert/debian-base
Bump debian-base build image to v1.4.3
2023-02-25 14:38:19 -08:00
Kubernetes Prow Robot abb41da1e9
Merge pull request #683 from KimHyeonwoo/patch-1
fix typo
2023-02-25 14:36:20 -08:00
Sascha Grunert c410fd4a62
Bump debian-base build image to v1.4.3
Signed-off-by: Sascha Grunert <sgrunert@redhat.com>
2023-02-22 12:35:40 +01:00
Tommy Hyeonwoo Kim 664fb74867
fix typo 2023-02-21 19:47:26 +09:00
Kubernetes Prow Robot 8fec7fa756
Merge pull request #680 from thockin/v4_git_tests
Add a test to exercise git
2023-02-17 11:50:02 -08:00