From 8739f267d1712cd243bffeb6556b194580ef20a3 Mon Sep 17 00:00:00 2001 From: Cyrus Katrak Date: Fri, 1 Nov 2019 12:32:41 -0700 Subject: [PATCH 1/2] flag for ignoring file mode / permissions --- statik.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/statik.go b/statik.go index be613c83..a7a34f61 100644 --- a/statik.go +++ b/statik.go @@ -41,6 +41,7 @@ var ( flagSrc = flag.String("src", path.Join(".", "public"), "The path of the source directory.") flagDest = flag.String("dest", ".", "The destination path of the generated package.") flagNoMtime = flag.Bool("m", false, "Ignore modification times on files.") + flagNoMode = flag.Bool("P", false, "Ignore file mode/permissions.") flagNoCompress = flag.Bool("Z", false, "Do not use compression to shrink the files.") flagForce = flag.Bool("f", false, "Overwrite destination file if it already exists.") flagTags = flag.String("tags", "", "Write build constraint tags") @@ -203,6 +204,11 @@ func generateSource(srcPath string, includes string) (file *os.File, err error) // Do NOT use fHeader.Modified as it only works on go >= 1.10 fHeader.SetModTime(mtimeDate) } + if *flagNoMode { + // Always use the same mode so that the output is deterministic with + // respect to file contents. + fHeader.SetMode(os.ModePerm) + } fHeader.Name = filepath.ToSlash(relPath) if !*flagNoCompress { fHeader.Method = zip.Deflate From 6eed2b2d86c8eab9937f83f9ae6308950218e1f9 Mon Sep 17 00:00:00 2001 From: Cy Date: Tue, 5 Nov 2019 10:57:28 -0800 Subject: [PATCH 2/2] Update statik.go --- statik.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/statik.go b/statik.go index a4b99dcf..32214c7f 100644 --- a/statik.go +++ b/statik.go @@ -39,7 +39,7 @@ var ( flagSrc = flag.String("src", path.Join(".", "public"), "") flagDest = flag.String("dest", ".", "") flagNoMtime = flag.Bool("m", false, "") - flagNoMode = flag.Bool("P", false, "") + flagNoMode = flag.Bool("P", false, "") flagNoCompress = flag.Bool("Z", false, "") flagForce = flag.Bool("f", false, "") flagTags = flag.String("tags", "", "")