git_lib 1.2.0 → 1.3.0.pre.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2c3b82cc9214aa0d0faecd8aa639ae16fee57179d0be17aebc365ebebe52e43f
4
- data.tar.gz: 24b88e76619b9ab4138ebe07eca7c849f09377a2eec21afe384545d6e674df61
3
+ metadata.gz: b67afe61368367e9d2eb9465a835b27710832495d8a8b404408c3d8248a93180
4
+ data.tar.gz: 6f661d3724d7d67c851b8620c5ac6e4fa05bb4124241509de5a781a9c64d2750
5
5
  SHA512:
6
- metadata.gz: eb5e0a487b3adad39dc3bc3d3f3fe94097a143ea0d7fdbccef27d1f5515a4612e98ecd44251d7926b5c4d51aeffd1a0efd819db024564574089dc7428cb9b6f2
7
- data.tar.gz: 75f854dba8e98489dc373fd829c8792ba8fc581624f5b5191bce97978dba6eade70e89b42a4b16a20ef76f784f42f8c08984841eb246b6647e0e49b11471db92
6
+ metadata.gz: c907b7a750ee58d1a639633e7df7b7e7de6978b5f5aecb0c1c4b4fd95f1bc4e93b5bd507a912b010bf93abfecb02ca3e525f190f363ebc7f42bb69a1dc371902
7
+ data.tar.gz: a61b0196e8be976b61df55fc268ec8d1058d227c89d247fe9e6f936979c3564a52b53619ae11864320cdb82100fc652cc4b2f7430f8978136df9df61d8665338
@@ -0,0 +1,27 @@
1
+ ---
2
+ name: Build
3
+ on: [push]
4
+ jobs:
5
+ tests:
6
+ name: Unit Tests
7
+ runs-on: ubuntu-latest
8
+ strategy:
9
+ fail-fast: false
10
+ matrix:
11
+ ruby: [2.5, 2.6]
12
+ gemfile:
13
+ - Gemfile
14
+ - gemfiles/rails_4.gemfile
15
+ - gemfiles/rails_5.gemfile
16
+ - gemfiles/rails_6.gemfile
17
+ env:
18
+ BUNDLE_GEMFILE: ${{ matrix.gemfile }}
19
+ steps:
20
+ - uses: actions/checkout@v2
21
+ - uses: ruby/setup-ruby@v1
22
+ with:
23
+ ruby-version: ${{ matrix.ruby }}
24
+ bundler: 1.17.3
25
+ bundler-cache: true
26
+ - name: Unit tests
27
+ run: bundle exec rspec
@@ -23,7 +23,7 @@ jobs:
23
23
  uses: mindsers/changelog-reader-action@v1
24
24
  with:
25
25
  version: ${{ steps.tag_name.outputs.current_version }}
26
- path: ./CHANGELOG.md
26
+ path: ./CHANGELOG.md
27
27
  - name: Create Release
28
28
  id: create_release
29
29
  uses: actions/create-release@v1
data/CHANGELOG.md CHANGED
@@ -4,6 +4,10 @@ Inspired by [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
4
4
 
5
5
  Note: this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
6
 
7
+ ## [1.3.0] - Unreleased
8
+ ### Added
9
+ - Add `repository:` to `GitCommit`.
10
+
7
11
  ## [1.2.0] - 2020-07-13
8
12
  ### Added
9
13
  - Add support for Rails 5 and 6.
@@ -20,5 +24,6 @@ Note: this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0
20
24
  - Add magic frozen_string_literal: true comment everywhere.
21
25
  - Clean up Rakefile.
22
26
 
27
+ [1.3.0]: https://github.com/Invoca/git_lib/compare/v1.2.0...v1.3.0
23
28
  [1.2.0]: https://github.com/Invoca/git_lib/compare/v1.1.1...v1.2.0
24
29
  [1.1.1]: https://github.com/Invoca/git_lib/compare/v1.1.0...v1.1.1
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- git_lib (1.2.0)
4
+ git_lib (1.3.0.pre.1)
5
5
  activesupport (>= 4.2, < 7)
6
6
 
7
7
  GEM
data/lib/git/git.rb CHANGED
@@ -163,7 +163,7 @@ module Git
163
163
  )
164
164
  raw_output.split("\n").map do |row|
165
165
  commit_data = row.split("\t")
166
- GitCommit.new(commit_data[0], commit_data[4], DateTime.iso8601(commit_data[3]), commit_data[1], commit_data[2])
166
+ GitCommit.new(commit_data[0], commit_data[4], DateTime.iso8601(commit_data[3]), commit_data[1], commit_data[2], repository_name: @repository_name)
167
167
  end
168
168
  end
169
169
 
@@ -2,14 +2,15 @@
2
2
 
3
3
  module Git
4
4
  class GitCommit
5
- attr_reader :sha, :message, :commit_date, :author_name, :author_email
5
+ attr_reader :repository_name, :sha, :message, :commit_date, :author_name, :author_email
6
6
 
7
- def initialize(sha, message, commit_date, author_name, author_email)
7
+ def initialize(sha, message, commit_date, author_name, author_email, repository_name:)
8
8
  @sha = sha
9
9
  @message = message
10
10
  @commit_date = commit_date
11
11
  @author_email = author_email
12
12
  @author_name = author_name
13
+ @repository_name = repository_name
13
14
  end
14
15
 
15
16
  def to_s
@@ -23,12 +23,13 @@ module Git
23
23
  GitConflict.new(repository_name, branch_a_name, branch_b_name, file_list)
24
24
  end
25
25
 
26
- def self.create_commit(sha: '1234567890123456789012345678901234567890',
26
+ def self.create_commit(repository_name: 'repository',
27
+ sha: '1234567890123456789012345678901234567890',
27
28
  message: 'Commit message',
28
29
  author_name: 'Author Name',
29
30
  author_email: 'author@email.com',
30
31
  commit_date: Time.current)
31
- GitCommit.new(sha, message, commit_date, author_name, author_email)
32
+ GitCommit.new(sha, message, commit_date, author_name, author_email, repository_name: repository_name)
32
33
  end
33
34
 
34
35
  def self.create_sha
data/lib/git/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Git
4
- VERSION = '1.2.0'
4
+ VERSION = '1.3.0.pre.1'
5
5
  end
@@ -3,7 +3,7 @@
3
3
  require 'spec_helper'
4
4
  require_relative '../../../lib/git/git_branch.rb'
5
5
 
6
- describe 'Git::GitBranch' do
6
+ RSpec.describe 'Git::GitBranch' do
7
7
  it 'can be created' do
8
8
  last_modified_date = Time.current
9
9
  branch = Git::GitBranch.new('repository_name', 'name', last_modified_date, 'author_name', 'author@email.com')
@@ -0,0 +1,24 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+ require_relative '../../../lib/git/git_commit.rb'
5
+
6
+ RSpec.describe Git::GitCommit do
7
+ let(:sha) { 'aabb2345' }
8
+ let(:message) { 'TECH-1234: update comments' }
9
+ let(:commit_date) { '2021-08-23 10:03:00 -0700' }
10
+ let(:author_name) { 'John Doe' }
11
+ let(:author_email) { 'john@doe.com' }
12
+ let(:repository_name) { 'repository_name' }
13
+
14
+ it 'can be created' do
15
+ commit = Git::GitCommit.new(sha, message, commit_date, author_name, author_email, repository_name: repository_name)
16
+
17
+ expect(commit.sha).to eq(sha)
18
+ expect(commit.message).to eq(message)
19
+ expect(commit.commit_date).to eq(commit_date)
20
+ expect(commit.author_name).to eq(author_name)
21
+ expect(commit.author_email).to eq(author_email)
22
+ expect(commit.repository_name).to eq(repository_name)
23
+ end
24
+ end
@@ -3,7 +3,7 @@
3
3
  require 'spec_helper'
4
4
  require_relative '../../../lib/git/git_conflict.rb'
5
5
 
6
- describe 'Git::GitConflict' do
6
+ RSpec.describe 'Git::GitConflict' do
7
7
  it 'can be created' do
8
8
  conflict = Git::GitConflict.new('repository_name', 'branch_a', 'branch_b', ['file1', 'file2'])
9
9
 
@@ -3,7 +3,7 @@
3
3
  require 'spec_helper'
4
4
  require_relative '../../../lib/git/git_error.rb'
5
5
 
6
- describe 'Git::GitError' do
6
+ RSpec.describe 'Git::GitError' do
7
7
  it 'can be raised' do
8
8
  expect { raise Git::GitError.new('command', 200, 'error_message') }.to \
9
9
  raise_exception(Git::GitError, "Git command command failed with exit code 200. Message:\nerror_message")
@@ -4,7 +4,7 @@ require 'spec_helper'
4
4
  require_relative '../../../lib/git/git.rb'
5
5
 
6
6
  # rubocop:disable Metrics/LineLength
7
- describe 'Git::Git' do
7
+ RSpec.describe 'Git::Git' do
8
8
  include FakeFS::SpecHelpers
9
9
 
10
10
  def create_mock_open_status(status)
@@ -28,15 +28,17 @@ describe 'Git::Git' do
28
28
  end
29
29
  end
30
30
 
31
+ let(:repository_name) { 'repository_name' }
32
+
31
33
  it 'can be created' do
32
- git = Git::Git.new('repository_name')
34
+ git = Git::Git.new(repository_name)
33
35
 
34
36
  expect(git.repository_url).to eq('git@github.com:repository_name.git')
35
37
  expect(git.repository_path).to eq('/tmp/git/repository_name')
36
38
  end
37
39
 
38
40
  it 'can be created with a different cache path' do
39
- git = Git::Git.new('repository_name', git_cache_path: './mycache')
41
+ git = Git::Git.new(repository_name, git_cache_path: './mycache')
40
42
 
41
43
  expect(git.repository_url).to eq('git@github.com:repository_name.git')
42
44
  expect(git.repository_path).to eq('./mycache/repository_name')
@@ -44,7 +46,7 @@ describe 'Git::Git' do
44
46
 
45
47
  context 'with a git repository' do
46
48
  before do
47
- @git = Git::Git.new('repository_name')
49
+ @git = Git::Git.new(repository_name)
48
50
  end
49
51
 
50
52
  it 'can execute a command' do
@@ -145,21 +147,21 @@ describe 'Git::Git' do
145
147
 
146
148
  branch_list = []
147
149
  branch_list << Git::GitBranch.new(
148
- 'repository_name',
150
+ repository_name,
149
151
  'test_1',
150
152
  DateTime.iso8601('2015-10-19T17:58:24-0700'),
151
153
  'Nicholas Ellis',
152
154
  'nellis@invoca.com'
153
155
  )
154
156
  branch_list << Git::GitBranch.new(
155
- 'repository_name',
157
+ repository_name,
156
158
  'test_build',
157
159
  DateTime.iso8601('2015-10-19T15:03:22-0700'),
158
160
  'Bob Smith',
159
161
  'bob@invoca.com'
160
162
  )
161
163
  branch_list << Git::GitBranch.new(
162
- 'repository_name',
164
+ repository_name,
163
165
  'test_build_b',
164
166
  DateTime.iso8601('2015-10-19T16:52:40-0700'),
165
167
  'Nicholas Ellis',
@@ -186,7 +188,7 @@ describe 'Git::Git' do
186
188
  )
187
189
 
188
190
  conflict = Git::GitConflict.new(
189
- 'repository_name',
191
+ repository_name,
190
192
  '91/eb/WEB-1723_Ringswitch_DB_Conn_Loss',
191
193
  '85/t/trello_adwords_dashboard_tiles_auto_adjust_font_size',
192
194
  ['test/workers/adwords_detail_worker_test.rb', 'pegasus/backdraft/pegasus_dashboard/spec/views/call_cost_tile_spec.js']
@@ -215,7 +217,7 @@ describe 'Git::Git' do
215
217
  expect(@git).to receive(:reset)
216
218
 
217
219
  conflict = Git::GitConflict.new(
218
- 'repository_name',
220
+ repository_name,
219
221
  '91/eb/WEB-1723_Ringswitch_DB_Conn_Loss',
220
222
  '85/t/trello_adwords_dashboard_tiles_auto_adjust_font_size',
221
223
  [
@@ -377,8 +379,8 @@ describe 'Git::Git' do
377
379
  it 'can diff a branch' do
378
380
  mocked_output = ["efd778098239838c165ffab2f12ad293f32824c8\tAuthor 1\tauthor1@email.com\t2016-07-14T10:09:45-07:00\tMerge branch 'production'\n",
379
381
  "667f3e5347c48c04663209682642fd8d6d93fde2\tAuthor 2\tauthor2@email.com\t2016-07-14T16:46:35-07:00\tMerge pull request #5584 from Owner/repo/dimension_repair\n"].join
380
- expected_array = [Git::GitCommit.new('efd778098239838c165ffab2f12ad293f32824c8', "Merge branch 'production'", nil, 'Author 1', 'author1@email.com'),
381
- Git::GitCommit.new('667f3e5347c48c04663209682642fd8d6d93fde2', 'Merge pull request #5584 from Owner/repo/dimension_repair', nil, 'Author 2', 'author2@email.com')]
382
+ expected_array = [Git::GitCommit.new('efd778098239838c165ffab2f12ad293f32824c8', "Merge branch 'production'", nil, 'Author 1', 'author1@email.com', repository_name: repository_name),
383
+ Git::GitCommit.new('667f3e5347c48c04663209682642fd8d6d93fde2', 'Merge pull request #5584 from Owner/repo/dimension_repair', nil, 'Author 2', 'author2@email.com', repository_name: repository_name)]
382
384
  mock_execute(
383
385
  mocked_output,
384
386
  1,
data/spec/spec_helper.rb CHANGED
@@ -7,14 +7,22 @@ require 'pp'
7
7
  require 'fakefs/spec_helpers'
8
8
  require 'rspec_junit_formatter'
9
9
  require 'climate_control'
10
+ require 'rspec/support/object_formatter'
10
11
 
11
12
  RSpec.configure do |config|
12
13
  config.add_formatter RspecJunitFormatter, ENV['JUNIT_OUTPUT'] || 'spec/reports/rspec.xml'
14
+ RSpec::Support::ObjectFormatter.default_instance.max_formatted_output_length = 2_000
15
+
16
+ # Disable RSpec exposing methods globally on `Module` and `main`
17
+ config.disable_monkey_patching!
18
+
19
+ config.filter_run_when_matching :focus
13
20
 
14
21
  # Enable flags like --only-failures and --next-failure
15
22
  config.example_status_persistence_file_path = "spec/reports/.rspec_status"
16
23
 
17
24
  config.expect_with :rspec do |expectations|
25
+ expectations.syntax = :expect
18
26
  expectations.include_chain_clauses_in_custom_matcher_descriptions = true
19
27
  end
20
28
 
@@ -23,6 +31,8 @@ RSpec.configure do |config|
23
31
  end
24
32
  config.shared_context_metadata_behavior = :apply_to_host_groups
25
33
 
34
+ config.shared_context_metadata_behavior = :apply_to_host_groups
35
+
26
36
  def with_modified_env(options, &block)
27
37
  ClimateControl.modify(options, &block)
28
38
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: git_lib
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.3.0.pre.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Invoca Development
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-07-13 00:00:00.000000000 Z
11
+ date: 2021-08-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -38,10 +38,9 @@ extensions: []
38
38
  extra_rdoc_files: []
39
39
  files:
40
40
  - ".dependabot/config.yml"
41
+ - ".github/workflows/build.yml"
41
42
  - ".github/workflows/gem_release.yml"
42
43
  - ".gitignore"
43
- - ".jenkins/Jenkinsfile"
44
- - ".jenkins/ruby_build_pod.yml"
45
44
  - ".rspec"
46
45
  - ".rubocop.yml"
47
46
  - ".ruby-version"
@@ -65,6 +64,7 @@ files:
65
64
  - lib/git/version.rb
66
65
  - lib/git_lib.rb
67
66
  - spec/lib/git/git_branch_spec.rb
67
+ - spec/lib/git/git_commit_spec.rb
68
68
  - spec/lib/git/git_conflict_spec.rb
69
69
  - spec/lib/git/git_error_spec.rb
70
70
  - spec/lib/git/git_spec.rb
@@ -84,9 +84,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
84
84
  version: '0'
85
85
  required_rubygems_version: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - ">="
87
+ - - ">"
88
88
  - !ruby/object:Gem::Version
89
- version: '0'
89
+ version: 1.3.1
90
90
  requirements: []
91
91
  rubygems_version: 3.0.1
92
92
  signing_key:
@@ -94,6 +94,7 @@ specification_version: 4
94
94
  summary: Git wrapper library.
95
95
  test_files:
96
96
  - spec/lib/git/git_branch_spec.rb
97
+ - spec/lib/git/git_commit_spec.rb
97
98
  - spec/lib/git/git_conflict_spec.rb
98
99
  - spec/lib/git/git_error_spec.rb
99
100
  - spec/lib/git/git_spec.rb
data/.jenkins/Jenkinsfile DELETED
@@ -1,72 +0,0 @@
1
- #!/usr/bin/groovy
2
- @Library('jenkins-pipeline@v0.4.5')
3
- import com.invoca.docker.*;
4
-
5
- pipeline {
6
- agent {
7
- kubernetes {
8
- defaultContainer "ruby"
9
- yamlFile ".jenkins/ruby_build_pod.yml"
10
- }
11
- }
12
-
13
- environment {
14
- GITHUB_TOKEN = credentials('github_token')
15
- BUNDLE_GEM__FURY__IO = credentials('gemfury_deploy_token')
16
- }
17
-
18
- stages {
19
- stage('Setup') {
20
- steps {
21
- updateGitHubStatus('clean-build', 'pending', 'Running unit tests...')
22
- sh 'bundle install'
23
- sh 'bundle exec appraisal install'
24
- }
25
- }
26
-
27
- stage('Appraisals') {
28
- parallel {
29
- stage('Current') {
30
- environment { JUNIT_OUTPUT = 'spec/reports/current/rspec.xml' }
31
- steps { sh 'bundle exec rspec' }
32
- post { always { junit JUNIT_OUTPUT } }
33
- }
34
-
35
- stage('Rails 4') {
36
- environment { JUNIT_OUTPUT = 'spec/reports/rails-4/rspec.xml' }
37
- steps { sh 'bundle exec appraisal rails-4 rspec' }
38
- post { always { junit JUNIT_OUTPUT } }
39
- }
40
-
41
- stage('Rails 5') {
42
- environment { JUNIT_OUTPUT = 'spec/reports/rails-5/rspec.xml' }
43
- steps { sh 'bundle exec appraisal rails-5 rspec' }
44
- post { always { junit JUNIT_OUTPUT } }
45
- }
46
-
47
- stage('Rails 6') {
48
- environment { JUNIT_OUTPUT = 'spec/reports/rails-6/rspec.xml' }
49
- steps { sh 'bundle exec appraisal rails-6 rspec' }
50
- post { always { junit JUNIT_OUTPUT } }
51
- }
52
- }
53
- }
54
- }
55
-
56
- post {
57
- success { updateGitHubStatus('clean-build', 'success', 'Unit tests passed') }
58
- failure { updateGitHubStatus('clean-build', 'failure', 'Unit tests failed') }
59
- }
60
- }
61
-
62
- void updateGitHubStatus(String context, String status, String description) {
63
- gitHubStatus([
64
- repoSlug: 'Invoca/git_lib',
65
- sha: env.GIT_COMMIT,
66
- description: description,
67
- context: context,
68
- targetURL: env.RUN_DISPLAY_URL,
69
- token: env.GITHUB_TOKEN,
70
- status: status
71
- ])
72
- }
@@ -1,19 +0,0 @@
1
- ---
2
- apiVersion: v1
3
- kind: Pod
4
- metadata:
5
- labels:
6
- jenkins/git-lib: 'true'
7
- namespace: jenkins
8
- name: git-lib
9
- spec:
10
- containers:
11
- - name: ruby
12
- image: ruby:2.6.1
13
- tty: true
14
- resources:
15
- requests:
16
- memory: "100Mi"
17
- command:
18
- - cat
19
-