rfix 1.1.0.pre.147 → 1.2.0
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/.github/workflows/main.yml +38 -0
- data/Gemfile.lock +3 -1
- data/lib/rfix.rb +1 -0
- data/lib/rfix/branch.rb +1 -0
- data/lib/rfix/branches/head.rb +2 -0
- data/lib/rfix/branches/main.rb +1 -0
- data/lib/rfix/branches/name.rb +3 -1
- data/lib/rfix/branches/reference.rb +2 -0
- data/lib/rfix/branches/upstream.rb +2 -0
- data/lib/rfix/rake/paths.rb +2 -2
- data/lib/rfix/tracked.rb +1 -1
- data/lib/rfix/version.rb +1 -1
- data/rfix.gemspec +3 -0
- data/tasks/execute.rake +38 -0
- data/tasks/libgit2.rake +33 -0
- data/tasks/simple.rake +4 -0
- metadata +23 -9
- data/lib/rfix/commands/all.rb +0 -26
- data/path.rb +0 -7
- data/rugged.rb +0 -206
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: ef900d9367b33de2920d9023babdd0e4b8a9a9f3b64bcc546f50dda98770b965
|
|
4
|
+
data.tar.gz: d120d6254494a84b2f48f65c1922a27d03e66f64444fe51f9769502d3523e618
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: cb754a3d385e02dd9842ff61136cf41d62ab5a5b0543be8e5e0f14fbd4ac56dbe9a3b51823c78b786abfc77b54ef9c561356422857496cc1571405da25ecc8e0
|
|
7
|
+
data.tar.gz: be1b3e5dce4181b22a7e158f1ef8053fe642e8046ac8e8bb4c8dcb2594b58e58226bb977c24b1146ead6c03d6889eb14628af2c883cb5c92173f712c6a4e9dd0
|
|
@@ -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}}"
|
data/Gemfile.lock
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
rfix (1.
|
|
4
|
+
rfix (1.2.0)
|
|
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)
|
data/lib/rfix.rb
CHANGED
data/lib/rfix/branch.rb
CHANGED
data/lib/rfix/branches/head.rb
CHANGED
data/lib/rfix/branches/main.rb
CHANGED
data/lib/rfix/branches/name.rb
CHANGED
|
@@ -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}}}")
|
data/lib/rfix/rake/paths.rb
CHANGED
|
@@ -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 =
|
|
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
|
|
data/lib/rfix/tracked.rb
CHANGED
data/lib/rfix/version.rb
CHANGED
data/rfix.gemspec
CHANGED
|
@@ -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
|
+
elseif 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"
|
data/tasks/execute.rake
ADDED
|
@@ -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
|
data/tasks/libgit2.rake
ADDED
|
@@ -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
|
data/tasks/simple.rake
CHANGED
metadata
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: rfix
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.
|
|
4
|
+
version: 1.2.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Linus Oleander
|
|
8
|
-
autorequire:
|
|
8
|
+
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
11
|
date: 2020-07-21 00:00:00.000000000 Z
|
|
@@ -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"
|
|
@@ -236,7 +251,6 @@ files:
|
|
|
236
251
|
- lib/rfix/branches/reference.rb
|
|
237
252
|
- lib/rfix/branches/upstream.rb
|
|
238
253
|
- lib/rfix/cmd.rb
|
|
239
|
-
- lib/rfix/commands/all.rb
|
|
240
254
|
- lib/rfix/commands/branch.rb
|
|
241
255
|
- lib/rfix/commands/extensions/options.rb
|
|
242
256
|
- lib/rfix/commands/help.rb
|
|
@@ -271,13 +285,13 @@ files:
|
|
|
271
285
|
- lib/rfix/tracked_file.rb
|
|
272
286
|
- lib/rfix/untracked.rb
|
|
273
287
|
- lib/rfix/version.rb
|
|
274
|
-
- path.rb
|
|
275
288
|
- resources/ps.png
|
|
276
289
|
- rfix.gemspec
|
|
277
|
-
- rugged.rb
|
|
278
290
|
- tasks/bump.rake
|
|
279
291
|
- tasks/bundle.rake
|
|
280
292
|
- tasks/complex.rake
|
|
293
|
+
- tasks/execute.rake
|
|
294
|
+
- tasks/libgit2.rake
|
|
281
295
|
- tasks/simple.rake
|
|
282
296
|
- tasks/travis.rake
|
|
283
297
|
- tasks/vendor.rake
|
|
@@ -311,7 +325,7 @@ licenses:
|
|
|
311
325
|
- MIT
|
|
312
326
|
metadata:
|
|
313
327
|
homepage_uri: https://github.com/oleander/rfix-rb
|
|
314
|
-
post_install_message:
|
|
328
|
+
post_install_message:
|
|
315
329
|
rdoc_options: []
|
|
316
330
|
require_paths:
|
|
317
331
|
- lib
|
|
@@ -323,13 +337,13 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
323
337
|
version: 2.5.0
|
|
324
338
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
325
339
|
requirements:
|
|
326
|
-
- - "
|
|
340
|
+
- - ">="
|
|
327
341
|
- !ruby/object:Gem::Version
|
|
328
|
-
version:
|
|
342
|
+
version: '0'
|
|
329
343
|
requirements:
|
|
330
344
|
- git, v2.0+
|
|
331
345
|
rubygems_version: 3.0.3
|
|
332
|
-
signing_key:
|
|
346
|
+
signing_key:
|
|
333
347
|
specification_version: 4
|
|
334
348
|
summary: RuboCop CLI that only lints and auto-fixes code you committed by utilizing
|
|
335
349
|
`git-log` and `git-diff`
|
data/lib/rfix/commands/all.rb
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
# helper("help", binding)
|
|
2
|
-
# helper("rubocop", binding)
|
|
3
|
-
# helper("args", binding)
|
|
4
|
-
#
|
|
5
|
-
# summary "All"
|
|
6
|
-
#
|
|
7
|
-
# run do |opts, args, cmd|
|
|
8
|
-
# setup(opts, args) do |repo, files|
|
|
9
|
-
# q1 = "Are you sure you want to {{warning:auto-fix}} the {{warning:the entire folder}}"
|
|
10
|
-
# q2 = "Are you sure you want to {{warning:auto-fix}} everything in {{warning:#{files.join(", ")}?}}"
|
|
11
|
-
#
|
|
12
|
-
# begin
|
|
13
|
-
# if files.empty?
|
|
14
|
-
# unless CLI::UI.confirm(q1)
|
|
15
|
-
# exit 1
|
|
16
|
-
# end
|
|
17
|
-
# elsif CLI::UI.confirm(q2)
|
|
18
|
-
# exit 1
|
|
19
|
-
# end
|
|
20
|
-
# rescue Interrupt
|
|
21
|
-
# exit 1
|
|
22
|
-
# end
|
|
23
|
-
#
|
|
24
|
-
# Rfix.global_enable!
|
|
25
|
-
# end
|
|
26
|
-
# end
|
data/path.rb
DELETED
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
|