From 222248a34e3ca9764338130f73a292420b85bf9c Mon Sep 17 00:00:00 2001 From: Tim Bozeman Date: Mon, 18 Jun 2018 14:35:16 -0700 Subject: [PATCH] Add chown flag --- cmd/git-sync/main.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/cmd/git-sync/main.go b/cmd/git-sync/main.go index 8dafe40f8..4c95ed17a 100644 --- a/cmd/git-sync/main.go +++ b/cmd/git-sync/main.go @@ -58,6 +58,8 @@ var flMaxSyncFailures = flag.Int("max-sync-failures", envInt("GIT_SYNC_MAX_SYNC_ "the number of consecutive failures allowed before aborting (the first pull must succeed)") var flChmod = flag.Int("change-permissions", envInt("GIT_SYNC_PERMISSIONS", 0), "the file permissions to apply to the checked-out files") +var flChown = flag.String("change-ownership", envString("GIT_SYNC_OWNER", ""), + "the owner of the checked-out files (user:group)") var flUsername = flag.String("username", envString("GIT_SYNC_USERNAME", ""), "the username to use") @@ -325,6 +327,14 @@ func addWorktreeAndSwap(gitRoot, dest, branch, rev, hash string) error { } } + if *flChown != "" { + // set file owner + _, err = runCommand("", "chown", "-R", *flChown, worktreePath) + if err != nil { + return err + } + } + return updateSymlink(gitRoot, dest, worktreePath) }