rfix 1.1.0.pre.149 → 1.2.2.pre.172

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
  SHA256:
3
- metadata.gz: 5ee4030d1ce4edff85010c48d311687c118f875406c6191069296e59287bf92c
4
- data.tar.gz: d052536e2c5789b690f7c063d2b098c2be418de7b925c9778c0ce060b97ec87b
3
+ metadata.gz: 704cebdb37c95b97087becc1cca6fab240003915dec8ae8423ba4b41d8451834
4
+ data.tar.gz: d888590c884dd572f111799bcfb383d44e512dbd423d7a6a114c14e2ebbc8860
5
5
  SHA512:
6
- metadata.gz: dae811bfdd02a5d81ac9b47cf0cbb7954a568d9de950242f3d5c946d52831f0898466bc93784b7c0e978d5d9fe57d3a5474ee75508eab99d43908c6ebcd328f4
7
- data.tar.gz: 5c9458afa7c3b84e8be22963f7aa62aef4b4a22f406590050f970eaa1b72605e1cd5c3dcd550d564fc490e36cc792087fbf29bdf19000561bc654d91da762ff7
6
+ metadata.gz: 7725847efd4a1143f4e646c6bb99ef0e7b8cf30ac66fda0aabc09a588864d271b436c0f02b90a4632269d46a76f60a5d6bcdb5ae9fc0eca12c67a596e834b73b
7
+ data.tar.gz: 0162cf4c212c02167a505afad65de84363b1be6cc803ab0c2b7a05ebc6751c7423839df3ee70fb0d8b0ed7be87ef92a506c03082176e7077bbf0f23bd8111347
@@ -0,0 +1,38 @@
1
+ ---
2
+ name: pre-release
3
+ on: [push]
4
+ env:
5
+ RUBYGEMS_API_KEY: ${{secrets.RUBYGEMS_API_KEY}}
6
+ GITHUB_API_TOKEN: ${{secrets.API_KEY}}
7
+ jobs:
8
+ setup:
9
+ container: ruby:2.7
10
+ runs-on: ubuntu-latest
11
+ steps:
12
+ - uses: actions/checkout@v2
13
+
14
+ - run: apt-get update -y
15
+ - run: apt-get install -y bash git libffi-dev build-essential wget cmake
16
+
17
+ - run: gem install bundler
18
+ - run: bundle config build.rugged --use-system-libraries
19
+ - run: bundle config build.ffi --use-system-libraries
20
+ - run: gem install rake rspec colorize
21
+ - run: rake libgit2:install
22
+
23
+ - run: bundle install --path vendor/bundle
24
+ - run: rake execute:local execute:origin execute:lint execute:branch
25
+
26
+ - run: git config user.email "linus@oleander.io"
27
+ - run: git config user.name "Linus Oleander"
28
+
29
+ - name: Publish to RubyGems
30
+ run: |
31
+ mkdir -p $HOME/.gem
32
+ touch $HOME/.gem/credentials
33
+ chmod 0600 $HOME/.gem/credentials
34
+ printf -- "---\n:rubygems_api_key: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
35
+ gem build *.gemspec
36
+ gem push *.gem
37
+ env:
38
+ GEM_HOST_API_KEY: "Bearer ${{secrets.RUBYGEMS_API_KEY}}"
@@ -1,10 +1,11 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rfix (1.1.0)
4
+ rfix (1.2.2)
5
5
  cri (~> 2.15.10)
6
6
  listen (~> 3.0)
7
7
  rainbow (~> 3.0)
8
+ require_all (~> 3.0.0)
8
9
  rouge (~> 3.20)
9
10
  rubocop (>= 0.80)
10
11
  rugged (~> 1.0.0)
@@ -118,6 +119,7 @@ GEM
118
119
  ffi (~> 1.0)
119
120
  rchardet (1.8.0)
120
121
  regexp_parser (1.7.1)
122
+ require_all (3.0.0)
121
123
  rexml (3.2.4)
122
124
  rouge (3.21.0)
123
125
  rspec (3.9.0)
@@ -4,6 +4,7 @@
4
4
  # https://gist.github.com/skanev/9d4bec97d5a6825eaaf6
5
5
 
6
6
  require "cli/ui"
7
+ require "require_all"
7
8
  require "rfix/version"
8
9
  require "rfix/log"
9
10
  require "rfix/cmd"
@@ -1,5 +1,6 @@
1
1
  require "rfix/repository"
2
2
  require "rfix/error"
3
+ autoload_rel "branches/*.rb"
3
4
 
4
5
  module Rfix
5
6
  module Branch
@@ -1,3 +1,5 @@
1
+ require_relative "base"
2
+
1
3
  module Rfix
2
4
  class Branch::Head < Branch::Base
3
5
  def resolve(with:)
@@ -1,4 +1,5 @@
1
1
  require "rugged"
2
+ require_relative "base"
2
3
 
3
4
  module Rfix
4
5
  class Branch::Main < Branch::Base
@@ -1,3 +1,5 @@
1
+ require_relative "base"
2
+
1
3
  module Rfix
2
4
  class Branch::Name < Branch::Base
3
5
  attr_reader :name
@@ -10,7 +12,7 @@ module Rfix
10
12
  unless branch = with.branches[name]
11
13
  raise Branch::UnknownBranchError.new("Could not find branch {{error:#{name}}}")
12
14
  end
13
-
15
+
14
16
  with.lookup(with.merge_base(branch.target_id, with.head.target_id))
15
17
  rescue Rugged::ReferenceError
16
18
  raise Branch::UnknownBranchError.new("Could not find branch {{error:#{name}}}")
@@ -1,3 +1,5 @@
1
+ require_relative "base"
2
+
1
3
  module Rfix
2
4
  class Branch::Reference < Branch::Base
3
5
  attr_reader :reference
@@ -1,3 +1,5 @@
1
+ require_relative "base"
2
+
1
3
  module Rfix
2
4
  class Branch::Upstream < Branch::Base
3
5
  def resolve(with:)
@@ -8,11 +8,11 @@ end
8
8
  module Bundle
9
9
  INSTALL = "bundle:install".freeze
10
10
  ADD = "bundle:git:add".freeze
11
- CONFIG = File.join(__dir__, "../../../.rubocop.yml")
12
11
  TAG = "rally-point".freeze
13
12
  REBUILD = "bundle:rebuild".freeze
14
13
  BUILD = "bundle:build".freeze
15
- ROOT = File.expand_path(File.join(__dir__, "../../.."))
14
+ ROOT = Dir.getwd
15
+ CONFIG = File.join(ROOT, ".rubocop.yml")
16
16
  DIR = File.join(ROOT, "spec/fixtures")
17
17
  TMP = File.join(ROOT, "tmp")
18
18
 
@@ -47,10 +47,13 @@ class Rfix::Repository
47
47
  end
48
48
 
49
49
  def include?(path, line)
50
+ say_debug "Checking #{path}:#{line}"
51
+
50
52
  if file = @files.get(path)
51
53
  return file.include?(line)
52
54
  end
53
55
 
56
+ say_debug "\tSkip file (return false)"
54
57
  return false
55
58
  end
56
59
 
@@ -5,6 +5,7 @@ class Rfix::Tracked < Rfix::File
5
5
 
6
6
  def include?(line)
7
7
  set = diff.each_line.to_a.map{ |l| l.new_lineno }.reject { |l| l == -1 }.to_set
8
+ say_debug "Does {{yellow:#{set}}} contain {{red:#{line}}}"
8
9
  set.include?(line)
9
10
  end
10
11
 
@@ -52,14 +53,10 @@ class Rfix::Tracked < Rfix::File
52
53
  end
53
54
 
54
55
  def diff
55
- upstream.diff(head, {
56
+ upstream.diff_workdir({
56
57
  include_untracked_content: true,
57
- # ignore_whitespace_change: true,
58
58
  recurse_untracked_dirs: true,
59
- disable_pathspec_match: false,
60
- # ignore_whitespace_eol: false,
61
59
  include_untracked: true,
62
- # ignore_whitespace: true,
63
60
  ignore_submodules: true,
64
61
  include_ignored: false,
65
62
  context_lines: 0,
@@ -67,7 +64,6 @@ class Rfix::Tracked < Rfix::File
67
64
  }).tap do |diff|
68
65
  diff.find_similar!(
69
66
  renames_from_rewrites: true,
70
- # ignore_whitespace: true,
71
67
  renames: true,
72
68
  copies: true
73
69
  )
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Rfix
4
- VERSION = "1.1.0"
4
+ VERSION = "1.2.2"
5
5
  end
@@ -11,6 +11,8 @@ Gem::Specification.new do |spec|
11
11
 
12
12
  if ENV["TRAVIS"]
13
13
  spec.version = "#{Rfix::VERSION}-#{ENV.fetch('TRAVIS_BUILD_NUMBER')}"
14
+ elsif ENV["GITHUB_RUN_ID"]
15
+ spec.version = "#{Rfix::VERSION}-#{ENV.fetch('GITHUB_RUN_ID')}"
14
16
  else
15
17
  # rubocop:disable Gemspec/DuplicatedAssignment
16
18
  spec.version = Rfix::VERSION
@@ -55,6 +57,7 @@ Gem::Specification.new do |spec|
55
57
  spec.add_runtime_dependency "rouge", "~> 3.20"
56
58
  spec.add_runtime_dependency "rubocop", ">= 0.80"
57
59
  spec.add_runtime_dependency "rugged", "~> 1.0.0"
60
+ spec.add_runtime_dependency "require_all", "~> 3.0.0"
58
61
 
59
62
  spec.add_development_dependency "rspec", "~> 3.0"
60
63
  spec.add_development_dependency "aruba", "~> 1.0"
@@ -0,0 +1,38 @@
1
+ require "rake/clean"
2
+ require "tmpdir"
3
+ require "pathname"
4
+
5
+ repo_path = Pathname.new(Dir.mktmpdir)
6
+
7
+ CLEAN.include(repo_path)
8
+
9
+ namespace :execute do
10
+ task local: [repo_path, :install] do
11
+ chdir(repo_path) do
12
+ sh "rfix local"
13
+ end
14
+ end
15
+
16
+ task branch: [repo_path, :install] do
17
+ chdir(repo_path) do
18
+ sh "rfix branch master"
19
+ end
20
+ end
21
+
22
+ task origin: [repo_path, :install] do
23
+ chdir(repo_path) do
24
+ sh "rfix origin"
25
+ end
26
+ end
27
+
28
+ task lint: [repo_path, :install] do
29
+ chdir(repo_path) do
30
+ sh "rfix lint"
31
+ end
32
+ end
33
+
34
+ file repo_path => :rebuild do
35
+ sh "git clone spec/fixtures/complex.bundle #{repo_path} --branch master"
36
+ sh "git --work-tree=#{repo_path} branch --set-upstream-to origin/master"
37
+ end
38
+ end
@@ -0,0 +1,33 @@
1
+ require "rake/clean"
2
+ require "tmpdir"
3
+ require "pathname"
4
+
5
+ root_path = Pathname.new(Dir.mktmpdir)
6
+ # root_path = Pathname.new(__dir__).join("../tmp")
7
+ libgit2_gz_path = root_path.join("v1.0.1.tar.gz")
8
+ libgit2_path = root_path.join("libgit2-1.0.1")
9
+
10
+ CLEAN.include(root_path)
11
+
12
+ namespace :libgit2 do
13
+ task build: libgit2_path do
14
+ chdir(libgit2_path) do
15
+ sh "cmake ."
16
+ sh "make"
17
+ end
18
+ end
19
+
20
+ task install: :build do
21
+ chdir(libgit2_path) do
22
+ sh "make install"
23
+ end
24
+ end
25
+
26
+ file libgit2_gz_path do
27
+ sh "wget -O #{libgit2_gz_path} https://github.com/libgit2/libgit2/archive/v1.0.1.tar.gz"
28
+ end
29
+
30
+ file libgit2_path => libgit2_gz_path do
31
+ sh "tar xzf #{libgit2_gz_path} -C #{root_path}"
32
+ end
33
+ end
@@ -42,6 +42,10 @@ namespace :bundle do
42
42
 
43
43
  sh "git init"
44
44
  sh "git add .gitignore"
45
+
46
+ sh "git config user.email 'you@example.com'"
47
+ sh "git config user.name 'Your Name'"
48
+
45
49
  sh "git commit -m 'A Commit Message'"
46
50
 
47
51
  sh "git config push.default current"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rfix
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0.pre.149
4
+ version: 1.2.2.pre.172
5
5
  platform: ruby
6
6
  authors:
7
7
  - Linus Oleander
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-07-21 00:00:00.000000000 Z
11
+ date: 2020-07-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: cri
@@ -94,6 +94,20 @@ dependencies:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
96
  version: 1.0.0
97
+ - !ruby/object:Gem::Dependency
98
+ name: require_all
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: 3.0.0
104
+ type: :runtime
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: 3.0.0
97
111
  - !ruby/object:Gem::Dependency
98
112
  name: rspec
99
113
  requirement: !ruby/object:Gem::Requirement
@@ -191,6 +205,7 @@ executables:
191
205
  extensions: []
192
206
  extra_rdoc_files: []
193
207
  files:
208
+ - ".github/workflows/main.yml"
194
209
  - ".gitignore"
195
210
  - ".rspec"
196
211
  - ".rubocop.yml"
@@ -270,13 +285,13 @@ files:
270
285
  - lib/rfix/tracked_file.rb
271
286
  - lib/rfix/untracked.rb
272
287
  - lib/rfix/version.rb
273
- - path.rb
274
288
  - resources/ps.png
275
289
  - rfix.gemspec
276
- - rugged.rb
277
290
  - tasks/bump.rake
278
291
  - tasks/bundle.rake
279
292
  - tasks/complex.rake
293
+ - tasks/execute.rake
294
+ - tasks/libgit2.rake
280
295
  - tasks/simple.rake
281
296
  - tasks/travis.rake
282
297
  - tasks/vendor.rake
data/path.rb DELETED
@@ -1,7 +0,0 @@
1
- require "jsonpath"
2
- require "json"
3
-
4
- json = JSON.parse(File.read("spec/fixtures/rubocop.json"))
5
- result = JsonPath.new("files[:][?(@.offenses[:].corrected==\"true\")].path").on(json)
6
-
7
- puts result
data/rugged.rb DELETED
@@ -1,206 +0,0 @@
1
- require "rugged"
2
- require "fileutils"
3
- require "rainbow"
4
- require "tmpdir"
5
- require "rfix"
6
- require 'shellwords'
7
- require "set"
8
-
9
- extend Rfix::Log
10
-
11
- # root_path = Dir.mktmpdir
12
- # at_exit { FileUtils.remove_dir(root_path) }
13
-
14
-
15
- # Dir.chdir(root_path) do
16
- # File.write(".gitignore", "# empty")
17
- # system "git init"
18
- # system "git add .gitignore"
19
- # system "git commit -a -m 'Test'"
20
- # end
21
-
22
-
23
- # class Git
24
- #
25
- # class Blob < Struct.new(:repo, :tree)
26
- # def commit(msg)
27
- # author = {:email=>"tanoku@gmail.com", :time=>Time.now, :name=>"Vicent Mart\303\255"}
28
- #
29
- # Rugged::Commit.create(repo,
30
- # :author => author,
31
- # :message => msg,
32
- # :committer => author,
33
- # :parents => parents,
34
- # :tree => tree,
35
- # :update_ref => "HEAD")
36
- # end
37
- #
38
- # def parents
39
- # repo.empty? ? [] : [ repo.head.target ].compact
40
- # end
41
- # end
42
- #
43
- # attr_reader :repo
44
- #
45
- # def initialize(root_path)
46
- # @repo = Rugged::Repository.new(root_path)
47
- # # @repo.index.read_tree(@repo.head.target.tree)
48
- # # @repo.index.reload
49
- # # @repo.index.write_tree(@repo)
50
- # end
51
- #
52
- # def blob(params)
53
- # abort "Must be a hash" unless params.is_a?(Hash)
54
- # debug("New blob")
55
- # index = repo.index
56
- # index.reload
57
- #
58
- # params.each do |path, content|
59
- # oid = repo.write(content, :blob)
60
- # index.read_tree(repo.head.target.tree)
61
- # index.add(path: path, oid: oid, mode: 0100644)
62
- # end
63
- #
64
- # Blob.new(repo, index.write_tree(repo))
65
- # end
66
- #
67
- # def has_branch?(name)
68
- # repo.branches.each_name().include?(name)
69
- # end
70
- #
71
- # def branch(name)
72
- # debug("Checkout branch #{name}")
73
- # if branch = repo.branches[name]
74
- # return repo.checkout(branch)
75
- # end
76
- #
77
- # repo.create_branch(name)
78
- # end
79
- #
80
- # def tag(name)
81
- # debug("Add tag #{name}")
82
- # repo.tags.create(name, "HEAD")
83
- # end
84
- #
85
- # def checkout(ref)
86
- # debug "Checkout ref #{ref}"
87
- # repo.checkout(ref)
88
- # end
89
- #
90
- # def status
91
- # debug "-- Get status"
92
- # repo.status do |file, status|
93
- # say "#{file} => #{status}"
94
- # end
95
- #
96
- # repo.index.entries.each do |entry|
97
- # say "Staged: #{entry}"
98
- # end
99
- # debug "-- End of status"
100
- # end
101
- #
102
- # def say(msg)
103
- # puts Rainbow("[LOG]").blue + " #{msg}"
104
- # end
105
- #
106
- # def debug(msg)
107
- # puts Rainbow("[DEBUG]").red + " #{msg}"
108
- # end
109
- #
110
- # def new_file(file, content)
111
- # debug "New file #{file}"
112
- # Dir.chdir(repo.workdir) do
113
- # File.write(file, content)
114
- # end
115
- #
116
- # file
117
- # end
118
- #
119
- # def add(file)
120
- # debug "Add file #{file}"
121
- # index = Rugged::Index.new(file)
122
- # index.write_tree(repo)
123
- # Blob.new(repo, index.write_tree(repo))
124
- # end
125
- # end
126
-
127
- # repo = Git.new(root_path)
128
- # repo.status
129
- # puts "------"
130
- # repo.branch("master")
131
- # repo.tag("v2")
132
- # repo.branch("mastsdkfjfsd")
133
- # repo.blob("example.rb" => "This is content").commit("This is my message")
134
- # repo.status
135
- # repo.checkout("v2")
136
- # repo.blob("valid.rb" => "This is content")
137
- # .commit("This is my message")
138
- # repo.blob("this.rb" => "This is content").commit("This is my message")
139
- # file = repo.new_file("valid.rb", "this is content")
140
- # repo.status
141
- # blob = repo.add(file)
142
- # repo.status
143
- # puts "----"
144
- # blob.commit("Okay!")
145
- # repo.status
146
-
147
- class AFile
148
- include Rfix::Log
149
- attr_reader :repo, :path
150
-
151
- def initialize(path, repo)
152
- @repo = repo
153
- @path = Shellwords.escape(path)
154
- refresh!
155
- end
156
-
157
- def include?(line)
158
- return true unless @changes
159
- @changes.include?(line)
160
- end
161
-
162
- def refresh!
163
- @changes = changed_lines
164
- rescue Rugged::TreeError
165
- @changed = nil
166
- end
167
-
168
- private
169
-
170
- def upstream
171
- @repo.rev_parse("@{u}:#{@path}")
172
- end
173
-
174
- def head
175
- @repo.rev_parse("HEAD:#{@path}")
176
- end
177
-
178
- def diff
179
- upstream.diff(head)
180
- end
181
-
182
- def changed_lines
183
- diff.each_hunk
184
- .to_a
185
- .map(&:lines)
186
- .flatten
187
- .map(&:new_lineno)
188
- .to_set
189
- end
190
- end
191
-
192
- repo = Rugged::Repository.new(".")
193
-
194
- repo.diff("83800375874a5ebd55b48283cef9245c32103aef", "HEAD").each_delta do |delta|
195
- pp delta.new_file.fetch(:path)
196
- end
197
- # files = `git ls-tree -r master --name-only`.lines.map(&:chomp)
198
- #
199
- # result = files.each_with_object({}) do |path, acc|
200
- # acc[path] = AFile.new(path, repo)
201
- # end
202
- #
203
- # pp reslt
204
-
205
- # binding.pry
206
- # repo.branches