git-shuffle 0.0.3 → 0.0.4

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 +1 -1
  3. data/bin/git-shuffle +27 -9
  4. data/lib/version.rb +2 -2
  5. metadata +4 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 692783b97bf1a927bf97d633ab89135b9b7d43f1
4
- data.tar.gz: 0b7c60a3c63d4c7bcffc36605fc78432521cf700
3
+ metadata.gz: 1a1d3eff65bae439bbc452eb988ac9af9f969c57
4
+ data.tar.gz: a43424ecb3d6f32e0fc8ac754314bf9f1aa6456a
5
5
  SHA512:
6
- metadata.gz: 199b27c2f2aa0f07504e1444bd77f0faa8ef4d25bb13734e2d59e37fb087e5b708800eaf014fb7de946ed662cb41c92c6dd30d2ead952920fecf5e3392abdfd0
7
- data.tar.gz: b09b3d51e5275758b08ff5f2017241983e8cb8d8140067fc0513ac612ff8eebc2d3b8b91505c106b823e772553456e76d8133c6977227563bd43df366aa19570
6
+ metadata.gz: 19996011a8b5964c01aa797d9bb6e3ade3a3bc0f360d97ef6690338a7ffbd50d242e58dd000379dd7b57aa03ad5545105fc78f85f34ccaa9cde0bedd10a1f428
7
+ data.tar.gz: ddad6ee3b8380140595311d707ae454254da49e40c2460df1c55630248fc972d7d42ae990e962863e434332c3739f2a51b2441ba8082a2487f6018757f685559
data/README.md CHANGED
@@ -16,6 +16,6 @@ git-shuffle
16
16
  ```bash
17
17
  gem build git-shuffle.gemspec
18
18
  gem install --local git-shuffle-<version>.gem
19
- cd <destination>
19
+ cd <repository>
20
20
  git-shuffle
21
21
  ```
@@ -6,25 +6,34 @@ require 'optparse'
6
6
 
7
7
  options = {}
8
8
  OptionParser.new do |opts|
9
- opts.banner = "Usage: date-shuffle [options]"
9
+ opts.banner = "Usage: git-shuffle [options]"
10
10
 
11
11
  opts.on("-p path", "--path=path", "Path to the target respository") do |path|
12
12
  options[:path] = path
13
13
  end
14
+ opts.on("-i interval", "--interval=interval", "How frequent is repo updated in days") do |interval|
15
+ options[:interval] = interval.to_i
16
+ end
17
+ opts.on("-a author", "--author=author", "Author of all commits") do |author|
18
+ options[:author] = author
19
+ puts "Setting author email to #{author}..."
20
+ end
21
+ opts.on("-c committer", "--committer=committer", "Committer of all commits") do |committer|
22
+ options[:committer] = committer
23
+ puts "Setting committer email to #{committer}..."
24
+ end
14
25
  end.parse!
15
26
 
16
- if options[:path] == nil
17
- puts 'Using current directory...'
18
- options[:path] = Dir.pwd
19
- end
20
27
 
21
- Dir.chdir options[:path]
28
+ options[:path] = Dir.pwd if options[:path] == nil
29
+ options[:interval] = 7 if options[:interval] == nil
22
30
 
23
- spread_factor = 4 # 1 commit every 4 days in average
31
+ Dir.chdir options[:path]
32
+ puts "Working directory: #{options[:path]}, #{options[:interval]} days per commit on average..."
24
33
 
25
34
  no_of_all_commits = %x(git log --pretty=format:"%H" | wc -w)
26
35
  no_of_all_commits = no_of_all_commits.to_i
27
- development_days_for_repo = no_of_all_commits * spread_factor
36
+ development_days_for_repo = no_of_all_commits * options[:interval]
28
37
  puts "Spreading #{no_of_all_commits} commits into #{development_days_for_repo} days."
29
38
 
30
39
  days_offset = []
@@ -45,8 +54,17 @@ days_offset.each do |offset|
45
54
  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
55
  puts "[#{index}/#{no_of_all_commits}] Set commit #{commit_hash} to #{offset} days ago: #{new_time}"
47
56
 
57
+ extra_cmd = ''
58
+ if options[:author]
59
+ extra_cmd += "export GIT_AUTHOR_EMAIL=#{options[:author]}; "
60
+ end
61
+ if options[:committer]
62
+ extra_cmd += "export GIT_COMMITTER_EMAIL=#{options[:committer]}; "
63
+ end
64
+
48
65
  command = <<-FOO
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/'"
66
+ 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}'; #{extra_cmd} fi && rm -fr '.git/refs/original/'"
50
67
  FOO
68
+ puts command
51
69
  system(command)
52
70
  end
@@ -1,5 +1,5 @@
1
1
 
2
2
  module GitShuffle
3
- VERSION = '0.0.3'
4
- DATE = '2019-09-12'
3
+ VERSION = '0.0.4'
4
+ DATE = '2019-09-13'
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.3
4
+ version: 0.0.4
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-12 00:00:00.000000000 Z
11
+ date: 2019-09-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: timerizer
@@ -37,7 +37,8 @@ files:
37
37
  homepage: http://rubygems.org/gems/git-shuffle
38
38
  licenses:
39
39
  - MIT
40
- metadata: {}
40
+ metadata:
41
+ source_code_uri: https://github.com/hex0cter/git-shuffle
41
42
  post_install_message:
42
43
  rdoc_options: []
43
44
  require_paths: