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.
Files changed (5) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +14 -0
  3. data/bin/git-shuffle +14 -15
  4. data/lib/version.rb +2 -2
  5. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f192e95725812cdb18c5d6c3089c33325a977d23
4
- data.tar.gz: 308208c30f79d4d4b152244e1459fd1318c870b8
3
+ metadata.gz: 692783b97bf1a927bf97d633ab89135b9b7d43f1
4
+ data.tar.gz: 0b7c60a3c63d4c7bcffc36605fc78432521cf700
5
5
  SHA512:
6
- metadata.gz: 38decbc5ce0ccd4486935aa431fe6021f3c60663084bcbc88ae6e6b089a6df5b838592c632681c5b950769d4446a78ac0f6758f73fe683b5d128859385d57f00
7
- data.tar.gz: bb1fb3657cca4798e1ef5c4ee54f369c2fb325a005f1b409b1ab66554b9400a3a78bd3f132b6b1286ff27c59a734502e952223757fb9e896300d7e89c1dfc72b
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: ruby date-shuffle.rb [options]"
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
- count = %x(git log --pretty=format:"%H" | wc -w)
26
- count = count.to_i
27
- # puts "there are #{count} commits in total"
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..365).to_a.sample(count).each do |num|
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
- i = 0
37
+ index = 0
37
38
 
38
39
  days_offset.each do |offset|
39
- i += 1
40
+ index += 1
40
41
 
41
- commit = %x(git log -#{i} --pretty=format:"%H" | tail -1)
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
- puts "[#{i}/#{count}] Set commit #{commit} to #{offset} days ago: #{date}"
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 = \'#{commit}\' ; then export GIT_AUTHOR_DATE='#{new_time.to_s}'; export GIT_COMMITTER_DATE='#{new_time.to_s}'; fi && rm -fr '.git/refs/original/'"
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
@@ -1,5 +1,5 @@
1
1
 
2
2
  module GitShuffle
3
- VERSION = '0.0.2'
4
- DATE = '2019-09-07'
3
+ VERSION = '0.0.3'
4
+ DATE = '2019-09-12'
5
5
  end
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.2
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-07 00:00:00.000000000 Z
11
+ date: 2019-09-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: timerizer