git-set-mtime 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e513ef240ab4454cde29eb56ce41e8a48c621dc0
4
- data.tar.gz: 3c0e454e96d48629d7ce7985d0e00c0c4cb63614
3
+ metadata.gz: 5fc52da49e7d8327c912fbe2400650fcdc9140f0
4
+ data.tar.gz: 92e3e6bacd2c73230148caeef5cf9b499ceadd51
5
5
  SHA512:
6
- metadata.gz: c36d78aee5183654d4ff75b4335e1fc384076dd22e8f013b55b0c14330c8cf15546e550ae05a063b6a62af1c2ab00c73fafbc58b1ae36caa5e976c6323201dc2
7
- data.tar.gz: da56a0e6693f9ce16aa71cabf399e1738ccdcd08a43395d9a6c6081dc3b0c28ea976b5490b8795f93feee8b05def1a8e767ec56ff2b01cb07476d3421c9e26bf
6
+ metadata.gz: 3e701f417d79e1c53c46f140be061443d03803cdea814e8b6b58bd04fbf0622717dd9fb02fa0ba5a20bd45d536b21396401e65b2985ea0d570d5ad72a2baaaed
7
+ data.tar.gz: 7c3eda02232a727c3bd3f68e8d35ebbfee52b47b9a605e18ee0d53b63acdc46f6c12fb6a3b6f595ebb5560e7901d07da33d625dd4c1a9bd2db90a9838a661ce2
data/.gitignore CHANGED
@@ -12,3 +12,4 @@
12
12
  *.o
13
13
  *.a
14
14
  mkmf.log
15
+ /git-set-mtime
data/README.md CHANGED
@@ -6,10 +6,13 @@ for Dockerfile building on CI servers(docker checking mtime for build cache)
6
6
 
7
7
  ## Installation
8
8
 
9
- Install it yourself as:
9
+ Install by rubygems:
10
10
 
11
11
  $ gem install git-set-mtime
12
12
 
13
+ Install by golang:
14
+ $ go get github.com/rosylilly/git-set-mtime
15
+
13
16
  ## Usage
14
17
 
15
18
  ```shell
@@ -9,7 +9,7 @@ module Git::Set::Mtime
9
9
  files = `git ls-files`
10
10
  files.each_line do |file|
11
11
  file = file.strip
12
- mtime_str = `git log -n 1 --date=local | head -n 3 | tail -n 1`.tr('Date:', '').strip
12
+ mtime_str = `git log -n 1 --date=local #{file} | head -n 3 | tail -n 1`.tr('Date:', '').strip
13
13
  mtime = Time.parse(mtime_str)
14
14
  File.utime(File.atime(file), mtime, file)
15
15
  puts "#{mtime} #{file}"
@@ -1,7 +1,7 @@
1
1
  module Git
2
2
  module Set
3
3
  module Mtime
4
- VERSION = "0.0.1"
4
+ VERSION = "0.0.2"
5
5
  end
6
6
  end
7
7
  end
data/main.go ADDED
@@ -0,0 +1,54 @@
1
+ package main
2
+
3
+ import (
4
+ "fmt"
5
+ "os"
6
+ "os/exec"
7
+ "strings"
8
+ "syscall"
9
+ "time"
10
+ )
11
+
12
+ const rfc2822 = "Mon, 02 Jan 2006 15:04:05 -0700"
13
+
14
+ func main() {
15
+ lsFiles := exec.Command("git", "ls-files", "-z")
16
+
17
+ out, err := lsFiles.Output()
18
+ if err != nil {
19
+ fmt.Fprint(os.Stderr, err)
20
+ os.Exit(1)
21
+ }
22
+
23
+ files := strings.Split(strings.TrimRight(string(out), "\x00"), "\x00")
24
+ for _, file := range files {
25
+ gitLog := exec.Command(
26
+ "/bin/sh", "-c",
27
+ fmt.Sprintf("git log -n 1 --date=rfc2822 %s | head -n 3 | tail -n 1", file),
28
+ )
29
+
30
+ out, err := gitLog.Output()
31
+
32
+ if err != nil {
33
+ fmt.Fprint(os.Stderr, err)
34
+ os.Exit(1)
35
+ }
36
+
37
+ mStr := strings.TrimSpace(strings.TrimLeft(string(out), "Date:"))
38
+ mTime, err := time.Parse(rfc2822, mStr)
39
+
40
+ if err != nil {
41
+ fmt.Fprint(os.Stderr, err)
42
+ os.Exit(1)
43
+ }
44
+
45
+ mTimeval := syscall.NsecToTimeval(mTime.UnixNano())
46
+ times := []syscall.Timeval{
47
+ mTimeval,
48
+ mTimeval,
49
+ }
50
+ syscall.Utimes(file, times)
51
+
52
+ fmt.Printf("%s: %s\n", file, mTime)
53
+ }
54
+ }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: git-set-mtime
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sho Kusano
@@ -69,6 +69,7 @@ files:
69
69
  - git-set-mtime.gemspec
70
70
  - lib/git/set/mtime.rb
71
71
  - lib/git/set/mtime/version.rb
72
+ - main.go
72
73
  homepage: https://github.com/rosylilly/git-set-mtime
73
74
  licenses:
74
75
  - MIT