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 +4 -4
- data/.gitignore +1 -0
- data/README.md +4 -1
- data/lib/git/set/mtime.rb +1 -1
- data/lib/git/set/mtime/version.rb +1 -1
- data/main.go +54 -0
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5fc52da49e7d8327c912fbe2400650fcdc9140f0
|
4
|
+
data.tar.gz: 92e3e6bacd2c73230148caeef5cf9b499ceadd51
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3e701f417d79e1c53c46f140be061443d03803cdea814e8b6b58bd04fbf0622717dd9fb02fa0ba5a20bd45d536b21396401e65b2985ea0d570d5ad72a2baaaed
|
7
|
+
data.tar.gz: 7c3eda02232a727c3bd3f68e8d35ebbfee52b47b9a605e18ee0d53b63acdc46f6c12fb6a3b6f595ebb5560e7901d07da33d625dd4c1a9bd2db90a9838a661ce2
|
data/.gitignore
CHANGED
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
|
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
|
data/lib/git/set/mtime.rb
CHANGED
@@ -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}"
|
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.
|
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
|