git-shuffle 0.0.2 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +14 -0
- data/bin/git-shuffle +14 -15
- data/lib/version.rb +2 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 692783b97bf1a927bf97d633ab89135b9b7d43f1
|
4
|
+
data.tar.gz: 0b7c60a3c63d4c7bcffc36605fc78432521cf700
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 199b27c2f2aa0f07504e1444bd77f0faa8ef4d25bb13734e2d59e37fb087e5b708800eaf014fb7de946ed662cb41c92c6dd30d2ead952920fecf5e3392abdfd0
|
7
|
+
data.tar.gz: b09b3d51e5275758b08ff5f2017241983e8cb8d8140067fc0513ac612ff8eebc2d3b8b91505c106b823e772553456e76d8133c6977227563bd43df366aa19570
|
data/README.md
CHANGED
@@ -1,3 +1,17 @@
|
|
1
|
+
# git-shuffle
|
2
|
+
Shuffle your git commits date and spread them throughout the year.
|
3
|
+
|
4
|
+
## How to install
|
5
|
+
```bash
|
6
|
+
gem install git-shuffle
|
7
|
+
```
|
8
|
+
|
9
|
+
## How to use
|
10
|
+
```bash
|
11
|
+
cd <repository>
|
12
|
+
git-shuffle
|
13
|
+
```
|
14
|
+
|
1
15
|
## How to test locally
|
2
16
|
```bash
|
3
17
|
gem build git-shuffle.gemspec
|
data/bin/git-shuffle
CHANGED
@@ -6,15 +6,13 @@ require 'optparse'
|
|
6
6
|
|
7
7
|
options = {}
|
8
8
|
OptionParser.new do |opts|
|
9
|
-
opts.banner = "Usage:
|
9
|
+
opts.banner = "Usage: date-shuffle [options]"
|
10
10
|
|
11
11
|
opts.on("-p path", "--path=path", "Path to the target respository") do |path|
|
12
|
-
puts path
|
13
12
|
options[:path] = path
|
14
13
|
end
|
15
14
|
end.parse!
|
16
15
|
|
17
|
-
|
18
16
|
if options[:path] == nil
|
19
17
|
puts 'Using current directory...'
|
20
18
|
options[:path] = Dir.pwd
|
@@ -22,32 +20,33 @@ end
|
|
22
20
|
|
23
21
|
Dir.chdir options[:path]
|
24
22
|
|
25
|
-
|
26
|
-
|
27
|
-
|
23
|
+
spread_factor = 4 # 1 commit every 4 days in average
|
24
|
+
|
25
|
+
no_of_all_commits = %x(git log --pretty=format:"%H" | wc -w)
|
26
|
+
no_of_all_commits = no_of_all_commits.to_i
|
27
|
+
development_days_for_repo = no_of_all_commits * spread_factor
|
28
|
+
puts "Spreading #{no_of_all_commits} commits into #{development_days_for_repo} days."
|
28
29
|
|
29
30
|
days_offset = []
|
30
|
-
(1..
|
31
|
+
(1..development_days_for_repo).to_a.sample(no_of_all_commits).each do |num|
|
31
32
|
days_offset << num
|
32
33
|
end
|
33
34
|
|
34
35
|
days_offset.sort!
|
35
36
|
|
36
|
-
|
37
|
+
index = 0
|
37
38
|
|
38
39
|
days_offset.each do |offset|
|
39
|
-
|
40
|
+
index += 1
|
40
41
|
|
41
|
-
|
42
|
+
commit_hash = %x(git log -#{index} --pretty=format:"%H" | tail -1)
|
42
43
|
|
43
|
-
# Sat, 14 Dec 2015 12:40:00 +0000
|
44
44
|
date = offset.days.ago
|
45
|
-
|
45
|
+
new_time = Time.new(date.year, date.month, date.day, (18..23).to_a.sample, (0..59).to_a.sample, (0..59).to_a.sample, "+02:00").to_s
|
46
|
+
puts "[#{index}/#{no_of_all_commits}] Set commit #{commit_hash} to #{offset} days ago: #{new_time}"
|
46
47
|
|
47
|
-
new_time = Time.new(date.year, date.month, date.day, (8..23).to_a.sample, (0..59).to_a.sample, (0..59).to_a.sample, "+02:00")
|
48
48
|
command = <<-FOO
|
49
|
-
git filter-branch -f --env-filter "if test \\$GIT_COMMIT = \'#{
|
49
|
+
git filter-branch -f --env-filter "if test \\$GIT_COMMIT = \'#{commit_hash}\' ; then export GIT_AUTHOR_DATE='#{new_time}'; export GIT_COMMITTER_DATE='#{new_time}'; fi && rm -fr '.git/refs/original/'"
|
50
50
|
FOO
|
51
|
-
# puts command
|
52
51
|
system(command)
|
53
52
|
end
|
data/lib/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: git-shuffle
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daniel Han
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-09-
|
11
|
+
date: 2019-09-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: timerizer
|