saddler-reporter-support-git 0.1.8 → 0.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b1be3da4bb0b294f83f818e1ccfc9031301483ea
4
- data.tar.gz: d410d009d669ce45ff284998450034aaac1b1c60
3
+ metadata.gz: 791fbc59ee6f9975cc615618032da76f14a566fb
4
+ data.tar.gz: 874531ac3acb2e0105ec6757d33d9b4d62306031
5
5
  SHA512:
6
- metadata.gz: dcbb55f3391a75a0c3b3b7b5cd296f3fb168130cd9851dded82f063043327e54bb760d8bac1af4adbc8c65f429ae0e4c2135cc0814615e675dcf4fab8fddc0b3
7
- data.tar.gz: 4abdda305707fb6e4c9f365a19bf6ebecec3a3704cae5dd47737aaf7f811427670f2820df270d9e9e56ef60c5088bce44d038debf3ffa601e35713d9fd5fe03a
6
+ metadata.gz: d2a8572d1667f8a45ffd920b25572f7fc10bb9c2fe4a0886d42706141408bebe25d2b76f1ba4d80ef442c8360278eec8cc74435c26dea524f93d2e5030c3d7b1
7
+ data.tar.gz: 6ae636cc3970b888a719386fe8a1f0c7fefaf0b203f57fab8290229be6424031194505325927ec24d09f382aea4efe6153ac3bc2f4687593d282b706cd669a0c
@@ -0,0 +1,17 @@
1
+ 'use strict';
2
+ var execSync = require('child_process').execSync;
3
+ var URI = require('urijs');
4
+
5
+ var gemspec = JSON.parse(execSync('bundle exec parse-gemspec-cli saddler-reporter-support-git.gemspec'));
6
+ var homepageUrl = gemspec.homepage;
7
+ var url = new URI(homepageUrl);
8
+ var host = url.protocol() + '://' + url.authority();
9
+ var owner = url.pathname().split('/')[1];
10
+ var repository = url.pathname().split('/')[2];
11
+
12
+ module.exports = {
13
+ version: gemspec.version,
14
+ host: host,
15
+ owner: owner,
16
+ repository: repository
17
+ };
data/.rubocop.yml CHANGED
@@ -12,6 +12,3 @@ Metrics/LineLength:
12
12
  Style/FileName:
13
13
  Exclude:
14
14
  - exe/*
15
-
16
- Style/RegexpLiteral:
17
- MaxSlashes: 0
data/.travis.yml CHANGED
@@ -1,15 +1,17 @@
1
- language: ruby
1
+ language: "ruby"
2
2
  sudo: false
3
3
  rvm:
4
- - 1.9
5
- - 2.0
6
- - 2.1
7
- - 2.2
4
+ - "1.9"
5
+ - "2.0"
6
+ - "2.1"
7
+ - "2.2"
8
+ - "ruby-head"
9
+ matrix:
10
+ allow_failures:
11
+ - rvm: "ruby-head"
8
12
  before_install:
9
- - gem update bundler
13
+ - "gem update bundler"
14
+ - "bin/setup"
10
15
  notifications:
11
16
  email:
12
17
  - ogataken@gmail.com
13
- branches:
14
- only:
15
- - master
data/CHANGELOG.md CHANGED
@@ -1,28 +1,37 @@
1
- ## Change Log
1
+ <a name="0.2.0"></a>
2
+ # [0.2.0](https://github.com/packsaddle/ruby-saddler-reporter-support-git/compare/v0.1.8...v0.2.0) (2015-09-29)
2
3
 
3
- ### v0.1.8 (2015/07/27 00:01 +00:00)
4
+ * **branch:** use `env_branch`.
5
+
6
+ ### Bug Fixes
7
+
8
+ * **endpoint:** empty string brings unexpected behavior ([94d245a](https://github.com/packsaddle/ruby-saddler-reporter-support-git/commit/94d245a))
9
+ * **git:** remove deperecated method #master and #origin_master ([546fdaf](https://github.com/packsaddle/ruby-saddler-reporter-support-git/commit/546fdaf))
10
+
11
+
12
+ # v0.1.8 (2015/07/27 00:01 +00:00)
4
13
  - [#16](https://github.com/packsaddle/ruby-saddler-reporter-support-git/pull/16) fix(merging-sha): remove hard-corded branch name (@sanemat)
5
14
  - [#14](https://github.com/packsaddle/ruby-saddler-reporter-support-git/pull/14) chore(gem): relax dependencies (@sanemat)
6
15
  - [#13](https://github.com/packsaddle/ruby-saddler-reporter-support-git/pull/13) chore(changelog): use github-changes (@sanemat)
7
16
 
8
- ### v0.1.7 (2015/03/06 08:45 +00:00)
17
+ # v0.1.7 (2015/03/06 08:45 +00:00)
9
18
  - [#11](https://github.com/packsaddle/ruby-saddler-reporter-support-git/pull/11) chore(gem): use git_clone_url (@sanemat)
10
19
 
11
- ### v0.1.6 (2015/03/05 18:23 +00:00)
20
+ # v0.1.6 (2015/03/05 18:23 +00:00)
12
21
  - [#10](https://github.com/packsaddle/ruby-saddler-reporter-support-git/pull/10) Revert "Merge pull request #9 from packsaddle/chore/use-uri-sshgit" (@sanemat)
13
22
 
14
- ### v0.1.5 (2015/03/05 03:44 +00:00)
23
+ # v0.1.5 (2015/03/05 03:44 +00:00)
15
24
  - [#9](https://github.com/packsaddle/ruby-saddler-reporter-support-git/pull/9) chore(gem): use uri-ssh_git instead of addressable if ssh protocol (@sanemat)
16
25
  - [#8](https://github.com/packsaddle/ruby-saddler-reporter-support-git/pull/8) chore(travisci): power-assert v0.2.3 (@sanemat)
17
26
 
18
- ### v0.1.4 (2015/02/26 05:53 +00:00)
27
+ # v0.1.4 (2015/02/26 05:53 +00:00)
19
28
  - [#7](https://github.com/packsaddle/ruby-saddler-reporter-support-git/pull/7) feat(circleci): detect circle ci branch (@sanemat)
20
29
 
21
- ### v0.1.3 (2015/02/25 14:01 +00:00)
30
+ # v0.1.3 (2015/02/25 14:01 +00:00)
22
31
  - [#6](https://github.com/packsaddle/ruby-saddler-reporter-support-git/pull/6) feat(merging object): add merging object implementation (@sanemat)
23
32
 
24
- ### v0.1.2 (2015/02/25 09:44 +00:00)
33
+ # v0.1.2 (2015/02/25 09:44 +00:00)
25
34
  - [#4](https://github.com/packsaddle/ruby-saddler-reporter-support-git/pull/4) Refactor/test git repo mocha (@sanemat)
26
35
 
27
- ### v0.1.1 (2015/02/24 17:37 +00:00)
36
+ # v0.1.1 (2015/02/24 17:37 +00:00)
28
37
  - [#1](https://github.com/packsaddle/ruby-saddler-reporter-support-git/pull/1) feat(travis): add env current branch (@sanemat)
data/Gemfile CHANGED
@@ -5,3 +5,6 @@ gemspec
5
5
 
6
6
  gem 'byebug' if RUBY_VERSION >= '2.0.0'
7
7
  gem 'pry'
8
+ gem 'rubocop'
9
+ gem 'parse_gemspec-cli'
10
+ gem 'yard'
data/README.md CHANGED
@@ -1,7 +1,31 @@
1
1
  # Saddler::Reporter::Support::Git
2
2
 
3
- [![Gem Version](http://img.shields.io/gem/v/saddler-reporter-support-git.svg?style=flat)](http://badge.fury.io/rb/saddler-reporter-support-git)
4
- [![Build Status](http://img.shields.io/travis/packsaddle/ruby-saddler-reporter-support-git/master.svg?style=flat)](https://travis-ci.org/packsaddle/ruby-saddler-reporter-support-git)
3
+ [![Gem version][gem-image]][gem-url] [![Travis-CI Status][travis-image]][travis-url] [![yard docs][docs-image]][docs-url]
4
+
5
+ > Utilities for Saddler reporter and git repository.
6
+
7
+
8
+ ## API
9
+
10
+
11
+ *[details][docs-url]*.
12
+
13
+
14
+ #### Build API document
15
+
16
+ ##### On local file
17
+
18
+ `bundle exec doc`.
19
+
20
+ ##### On local server
21
+
22
+ `bundle exec yard server -r` and `open http://localhost:8808`.
23
+
24
+
25
+ ## Changelog
26
+
27
+ [CHANGELOG.md](./CHANGELOG.md).
28
+
5
29
 
6
30
  ## Installation
7
31
 
@@ -19,18 +43,13 @@ Or install it yourself as:
19
43
 
20
44
  $ gem install saddler-reporter-support-git
21
45
 
46
+
22
47
  ## Development
23
48
 
24
49
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `bin/console` for an interactive prompt that will allow you to experiment.
25
50
 
26
51
  To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release` to create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
27
52
 
28
- ### Change log
29
-
30
- ```bash
31
- npm install -g github-changes
32
- github-changes -o packsaddle -r ruby-saddler-reporter-support-git --only-pulls --use-commit-body
33
- ```
34
53
 
35
54
  ## Contributing
36
55
 
@@ -39,3 +58,17 @@ github-changes -o packsaddle -r ruby-saddler-reporter-support-git --only-pulls -
39
58
  3. Commit your changes (`git commit -am 'Add some feature'`)
40
59
  4. Push to the branch (`git push origin my-new-feature`)
41
60
  5. Create a new Pull Request
61
+
62
+
63
+ ## License
64
+
65
+ © [sanemat](http://sane.jp)
66
+
67
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
68
+
69
+ [travis-url]: https://travis-ci.org/packsaddle/ruby-saddler-reporter-support-git
70
+ [travis-image]: https://img.shields.io/travis/packsaddle/ruby-saddler-reporter-support-git/master.svg?style=flat-square&label=build%20%28linux%29
71
+ [gem-url]: https://rubygems.org/gems/saddler-reporter-support-git
72
+ [gem-image]: http://img.shields.io/gem/v/saddler-reporter-support-git.svg?style=flat-square
73
+ [docs-url]: http://www.rubydoc.info/gems/saddler-reporter-support-git
74
+ [docs-image]: https://img.shields.io/badge/yard-docs-blue.svg?style=flat-square
data/Rakefile CHANGED
@@ -8,3 +8,12 @@ Rake::TestTask.new(:test) do |t|
8
8
  end
9
9
 
10
10
  task default: :test
11
+
12
+ require 'yard'
13
+ require 'yard/rake/yardoc_task'
14
+ DOC_FILES = ['lib/**/*.rb']
15
+ DOC_OPTIONS = ['--debug', '--verbose']
16
+ YARD::Rake::YardocTask.new(:doc) do |t|
17
+ t.files = DOC_FILES
18
+ t.options = DOC_OPTIONS if Rake.application.options.trace
19
+ end
data/bin/setup CHANGED
@@ -1,7 +1,15 @@
1
- #!/bin/bash
2
- set -euo pipefail
3
- IFS=$'\n\t'
1
+ #!/usr/bin/env ruby
4
2
 
5
- bundle install
6
-
7
- # Do any other automated setup that you need to do here
3
+ require 'open3'
4
+ unless ENV['CI']
5
+ out, err, status = Open3.capture3(*%w(bundle install))
6
+ $stdout.puts out
7
+ $stderr.puts err
8
+ exit status.exitstatus if !status.exitstatus.nil? && status.exitstatus != 0
9
+ end
10
+ unless ENV['CI']
11
+ out, err, status = Open3.capture3(*%w(npm install))
12
+ $stdout.puts out
13
+ $stderr.puts err
14
+ exit status.exitstatus if !status.exitstatus.nil? && status.exitstatus != 0
15
+ end
@@ -2,13 +2,21 @@ module Saddler
2
2
  module Reporter
3
3
  module Support
4
4
  module Git
5
+ # Git repository support utility for saddler-reporter
5
6
  class Repository
6
7
  attr_reader :git
8
+ # @!attribute [r] git
9
+ # @return [::Git] git repository object
7
10
 
11
+ # Build git repository support utility object
12
+ #
13
+ # @param path [String] working_dir
14
+ # @param options [Hash] Git.open options (see ::Git.open)
8
15
  def initialize(path, options = {})
9
16
  @git = ::Git.open(path, options)
10
17
  end
11
18
 
19
+ # @return [String] `user/repo` from remote_urls
12
20
  def slug
13
21
  slug_regex = %r{\A/(?<slug>.*?)(?:\.git)?\Z}
14
22
  remote_urls.map do |url|
@@ -18,20 +26,24 @@ module Saddler
18
26
  end.compact.first
19
27
  end
20
28
 
29
+ # @return [Array<String>] remote urls
21
30
  def remote_urls
22
31
  @git
23
32
  .remotes
24
33
  .map(&:url)
25
34
  end
26
35
 
36
+ # @return [String] current branch name
27
37
  def current_branch
28
38
  env_current_branch || @git.current_branch
29
39
  end
30
40
 
41
+ # @return [::Git::Object] git object for `HEAD`
31
42
  def head
32
43
  @git.object('HEAD')
33
44
  end
34
45
 
46
+ # @return [String] merging_object's sha
35
47
  def merging_sha
36
48
  merging_object.sha
37
49
  end
@@ -40,6 +52,8 @@ module Saddler
40
52
  # if head is commit which already merged,
41
53
  # head's parent objects include merging object
42
54
  # and (master or origin/master)
55
+ #
56
+ # @return [::Git::Object] merging object
43
57
  def merging_object
44
58
  return head unless merge_commit?(head)
45
59
  commit = head.parents.select do |parent|
@@ -49,31 +63,29 @@ module Saddler
49
63
  head # fallback
50
64
  end
51
65
 
52
- def master
53
- warn "[DEPRECATION] `#{self.class.name}#master` is deprecated. Please use `#tracking` instead."
54
- tracking
55
- end
56
-
66
+ # @return [::Git::Object] git object for `tracking_branch_name`
57
67
  def tracking
58
68
  @git.object(tracking_branch_name)
59
69
  end
60
70
 
61
- def origin_master
62
- warn "[DEPRECATION] `#{self.class.name}#origin_master` is deprecated. Please use `#origin_tracking` instead."
63
- origin_tracking
64
- end
65
-
71
+ # @return [::Git::Object] git object for `origin/tracking_branch_name`
66
72
  def origin_tracking
67
73
  @git.object("origin/#{tracking_branch_name}")
68
74
  end
69
75
 
76
+ # @return [::Git::Config] git config instance
70
77
  def config
71
78
  @git.config
72
79
  end
73
80
 
74
- # http://stackoverflow.com/questions/4950725/how-do-i-get-git-to-show-me-which-branches-are-tracking-what
75
- # { "branch.spike/no-valid-master.merge" => "refs/heads/develop" }
76
- # => "develop"
81
+ # @example tracking branch
82
+ # # from git config
83
+ # { "branch.spike/no-valid-master.merge" => "refs/heads/develop" }
84
+ # => "develop"
85
+ #
86
+ # @return [String] tracking branch name
87
+ #
88
+ # @see http://stackoverflow.com/questions/4950725/how-do-i-get-git-to-show-me-which-branches-are-tracking-what
77
89
  def tracking_branch_name
78
90
  config
79
91
  .select { |k, _| /\Abranch.*merge\Z/ =~ k }
@@ -86,30 +98,36 @@ module Saddler
86
98
  .shift
87
99
  end
88
100
 
101
+ # @param commit [::Git::Object]
102
+ #
103
+ # @return [Boolean] true if commit is a merge commit
89
104
  def merge_commit?(commit)
90
105
  commit.parents.count == 2
91
106
  end
92
107
 
108
+ # @return [String] push endpoint (defaults to: 'github.com')
93
109
  def push_endpoint
94
110
  (env_push_endpoint || 'github.com').chomp('/')
95
111
  end
96
112
 
97
- # e.g. 'github.com'
98
- # git@github.com:packsaddle/ruby-saddler-reporter-support-git.git
113
+ # @example via ssh
114
+ # 'git@github.com:packsaddle/ruby-saddler-reporter-support-git.git'
115
+ # #=> 'github.com'
116
+ #
117
+ # @return [String, nil] push endpoint from env
99
118
  def env_push_endpoint
100
- if ENV['PUSH_ENDPOINT']
101
- ENV['PUSH_ENDPOINT']
102
- end
119
+ ENV['PUSH_ENDPOINT'] if ENV['PUSH_ENDPOINT'] && !ENV['PUSH_ENDPOINT'].empty?
103
120
  end
104
121
 
122
+ # @return [String, nil] current branch name from env
105
123
  def env_current_branch
106
- if ENV['CURRENT_BRANCH']
107
- ENV['CURRENT_BRANCH']
108
- elsif ENV['TRAVIS_BRANCH']
109
- ENV['TRAVIS_BRANCH']
110
- elsif ENV['CIRCLE_BRANCH']
111
- ENV['CIRCLE_BRANCH']
124
+ env_branch = EnvBranch.new do
125
+ if ENV['CURRENT_BRANCH'] &&
126
+ !ENV['CURRENT_BRANCH'].empty?
127
+ ENV['CURRENT_BRANCH']
128
+ end
112
129
  end
130
+ env_branch.branch_name
113
131
  end
114
132
  end
115
133
  end
@@ -2,7 +2,7 @@ module Saddler
2
2
  module Reporter
3
3
  module Support
4
4
  module Git
5
- VERSION = '0.1.8'
5
+ VERSION = '0.2.0'
6
6
  end
7
7
  end
8
8
  end
@@ -1,13 +1,14 @@
1
1
  require 'git'
2
2
  require 'git_clone_url'
3
+ require 'env_branch'
3
4
  require 'saddler/reporter/support/git/version'
4
5
  require 'saddler/reporter/support/git/repository'
5
6
 
6
7
  module Saddler
7
8
  module Reporter
8
9
  module Support
10
+ # Git support utility for saddler-reporter
9
11
  module Git
10
- # Your code goes here...
11
12
  end
12
13
  end
13
14
  end
data/package.json ADDED
@@ -0,0 +1,11 @@
1
+ {
2
+ "devDependencies": {
3
+ "conventional-changelog": "^0.4.3",
4
+ "npm-check-updates": "^2.2.4",
5
+ "urijs": "^1.16.1"
6
+ },
7
+ "scripts": {
8
+ "changelog": "conventional-changelog -i CHANGELOG.md --overwrite --preset angular --context .conventional-changelog.context.js",
9
+ "ncu": "ncu -u"
10
+ }
11
+ }
@@ -21,6 +21,7 @@ Gem::Specification.new do |spec|
21
21
 
22
22
  spec.add_runtime_dependency 'git'
23
23
  spec.add_runtime_dependency 'git_clone_url'
24
+ spec.add_runtime_dependency 'env_branch'
24
25
 
25
26
  spec.add_development_dependency 'bundler'
26
27
  spec.add_development_dependency 'rake'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: saddler-reporter-support-git
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.8
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - sanemat
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-07-27 00:00:00.000000000 Z
11
+ date: 2015-09-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: git
@@ -38,6 +38,20 @@ dependencies:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: env_branch
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
41
55
  - !ruby/object:Gem::Dependency
42
56
  name: bundler
43
57
  requirement: !ruby/object:Gem::Requirement
@@ -101,6 +115,7 @@ executables: []
101
115
  extensions: []
102
116
  extra_rdoc_files: []
103
117
  files:
118
+ - ".conventional-changelog.context.js"
104
119
  - ".gitignore"
105
120
  - ".rubocop.yml"
106
121
  - ".tachikoma.yml"
@@ -116,6 +131,7 @@ files:
116
131
  - lib/saddler/reporter/support/git.rb
117
132
  - lib/saddler/reporter/support/git/repository.rb
118
133
  - lib/saddler/reporter/support/git/version.rb
134
+ - package.json
119
135
  - saddler-reporter-support-git.gemspec
120
136
  homepage: https://github.com/packsaddle/ruby-saddler-reporter-support-git
121
137
  licenses:
@@ -142,3 +158,4 @@ signing_key:
142
158
  specification_version: 4
143
159
  summary: Utilities for Saddler reporter and git repository.
144
160
  test_files: []
161
+ has_rdoc: