compare_linker_command 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/.ruby-version +1 -0
- data/CODE_OF_CONDUCT.md +49 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +51 -0
- data/Rakefile +2 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/compare_linker_command.gemspec +27 -0
- data/exe/create_pr_with_compare_linker +18 -0
- data/lib/compare_linker_command.rb +3 -0
- data/lib/compare_linker_command/executor.rb +78 -0
- data/lib/compare_linker_command/parser.rb +61 -0
- data/lib/compare_linker_command/version.rb +3 -0
- metadata +130 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: a81d3372ce6467796ea04ccd0236c575b607157a
|
4
|
+
data.tar.gz: 189c0fdb6f62b0ddcc6ef41186ee678706987feb
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: ce3db3fdfb578a53bf9e30bac0765e0204de58c2712c3f08297012a7d2d77bfb8d9f1ddea328495eacd94b505f892cae03f589ef2b13c74828191336c8122cb9
|
7
|
+
data.tar.gz: db7366681bc89a9773ab00384e375048b446d83b276c3b0340d4cfc5caff66b87af1e74c09b015af4ae7c3392cce0e18fd5f687156b228908083c4b68d8180d4
|
data/.gitignore
ADDED
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.4.3
|
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
# Contributor Code of Conduct
|
2
|
+
|
3
|
+
As contributors and maintainers of this project, and in the interest of
|
4
|
+
fostering an open and welcoming community, we pledge to respect all people who
|
5
|
+
contribute through reporting issues, posting feature requests, updating
|
6
|
+
documentation, submitting pull requests or patches, and other activities.
|
7
|
+
|
8
|
+
We are committed to making participation in this project a harassment-free
|
9
|
+
experience for everyone, regardless of level of experience, gender, gender
|
10
|
+
identity and expression, sexual orientation, disability, personal appearance,
|
11
|
+
body size, race, ethnicity, age, religion, or nationality.
|
12
|
+
|
13
|
+
Examples of unacceptable behavior by participants include:
|
14
|
+
|
15
|
+
* The use of sexualized language or imagery
|
16
|
+
* Personal attacks
|
17
|
+
* Trolling or insulting/derogatory comments
|
18
|
+
* Public or private harassment
|
19
|
+
* Publishing other's private information, such as physical or electronic
|
20
|
+
addresses, without explicit permission
|
21
|
+
* Other unethical or unprofessional conduct
|
22
|
+
|
23
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
24
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
25
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
26
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
27
|
+
threatening, offensive, or harmful.
|
28
|
+
|
29
|
+
By adopting this Code of Conduct, project maintainers commit themselves to
|
30
|
+
fairly and consistently applying these principles to every aspect of managing
|
31
|
+
this project. Project maintainers who do not follow or enforce the Code of
|
32
|
+
Conduct may be permanently removed from the project team.
|
33
|
+
|
34
|
+
This code of conduct applies both within project spaces and in public spaces
|
35
|
+
when an individual is representing the project or its community.
|
36
|
+
|
37
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
38
|
+
reported by contacting a project maintainer at yoshihara@users.noreply.github.com. All
|
39
|
+
complaints will be reviewed and investigated and will result in a response that
|
40
|
+
is deemed necessary and appropriate to the circumstances. Maintainers are
|
41
|
+
obligated to maintain confidentiality with regard to the reporter of an
|
42
|
+
incident.
|
43
|
+
|
44
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
|
45
|
+
version 1.3.0, available at
|
46
|
+
[http://contributor-covenant.org/version/1/3/0/][version]
|
47
|
+
|
48
|
+
[homepage]: http://contributor-covenant.org
|
49
|
+
[version]: http://contributor-covenant.org/version/1/3/0/
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2017 yoshihara
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
# CompareLinkerCommand
|
2
|
+
|
3
|
+
次のことを自動で行うコマンドです。
|
4
|
+
|
5
|
+
1. bundle update
|
6
|
+
2. Create PR
|
7
|
+
3. Compare Linker
|
8
|
+
|
9
|
+
オプションでPR番号を指定することで、既存のPRに対してCompareLinkerのみ実行することができます。
|
10
|
+
|
11
|
+
## Installation
|
12
|
+
|
13
|
+
```console
|
14
|
+
$ gem install compare_linker_command
|
15
|
+
```
|
16
|
+
|
17
|
+
## Usage
|
18
|
+
|
19
|
+
### normal:
|
20
|
+
|
21
|
+
```consome
|
22
|
+
$ create_pr_with_compare_linker \
|
23
|
+
--github-access-token YOUR_TOKEN \
|
24
|
+
--repo-name ORG/REPOSITORY \
|
25
|
+
--pr-body-file FILE_CONTAINING_PR_DESCRIPTION_CONTENT(optional)
|
26
|
+
```
|
27
|
+
|
28
|
+
### Compare Linker only:
|
29
|
+
|
30
|
+
```consome
|
31
|
+
$ create_pr_with_compare_linker \
|
32
|
+
--github-access-token YOUR_TOKEN \
|
33
|
+
--repo-name ORG/REPOSITORY \
|
34
|
+
--pr-number TARGET_PR_NUMBER
|
35
|
+
```
|
36
|
+
|
37
|
+
## Development
|
38
|
+
|
39
|
+
After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
40
|
+
|
41
|
+
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`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
42
|
+
|
43
|
+
## Contributing
|
44
|
+
|
45
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/compare_linker_command. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
46
|
+
|
47
|
+
|
48
|
+
## License
|
49
|
+
|
50
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
51
|
+
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "compare_linker_command"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'compare_linker_command/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "compare_linker_command"
|
8
|
+
spec.version = CompareLinkerCommand::VERSION
|
9
|
+
spec.authors = ["yoshihara"]
|
10
|
+
spec.email = ["yshr04hrk@gmail.com"]
|
11
|
+
|
12
|
+
spec.summary = "compare linker command"
|
13
|
+
spec.description = "compare linker command"
|
14
|
+
spec.homepage = "https://github.com/yoshihara/compare_linker_command"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
18
|
+
spec.bindir = "exe"
|
19
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
20
|
+
spec.require_paths = ["lib"]
|
21
|
+
|
22
|
+
spec.add_dependency "git", "~> 1.3.0"
|
23
|
+
spec.add_dependency "octokit", "~> 4.7.0"
|
24
|
+
spec.add_dependency "compare_linker", "~> 1.3.8"
|
25
|
+
spec.add_development_dependency "bundler", "~> 1.11"
|
26
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
27
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "compare_linker_command"
|
4
|
+
|
5
|
+
params = CompareLinkerCommand::Parser.parse(ARGV)
|
6
|
+
|
7
|
+
unless params[:succeeded]
|
8
|
+
exit(false)
|
9
|
+
end
|
10
|
+
|
11
|
+
current_dir = Dir.pwd
|
12
|
+
command = CompareLinkerCommand::Executor.new(current_dir, params)
|
13
|
+
|
14
|
+
if params[:pr_number]
|
15
|
+
command.run_compare_linker(params[:pr_number])
|
16
|
+
else
|
17
|
+
command.exec
|
18
|
+
end
|
@@ -0,0 +1,78 @@
|
|
1
|
+
require "compare_linker"
|
2
|
+
require "git"
|
3
|
+
require "octokit"
|
4
|
+
|
5
|
+
module CompareLinkerCommand
|
6
|
+
class Executor
|
7
|
+
def initialize(current_dir, params)
|
8
|
+
@current_dir = current_dir
|
9
|
+
|
10
|
+
@repo_name = params[:repo_name]
|
11
|
+
@pr_body = params[:pr_body_file] ? File.read(params[:pr_body_file]) : ""
|
12
|
+
|
13
|
+
@local = Git.open(current_dir)
|
14
|
+
|
15
|
+
@token = params[:token]
|
16
|
+
@remote = Octokit::Client.new(access_token: @token)
|
17
|
+
end
|
18
|
+
|
19
|
+
def exec
|
20
|
+
$stdout.print "Create PR for '#{@current_dir}' (Ctrl-C for Cancel) :"
|
21
|
+
$stdin.gets
|
22
|
+
|
23
|
+
branch_name = "bundle_update_" + Date.today.strftime("%Y_%m_%d")
|
24
|
+
commit_message = "bundle update " + Date.today.strftime("%Y.%m.%d")
|
25
|
+
pr_title = commit_message
|
26
|
+
|
27
|
+
$stdout.puts "Stash"
|
28
|
+
$stdout.puts `git stash`
|
29
|
+
|
30
|
+
$stdout.puts "Checkout master & pull"
|
31
|
+
@local.branch("master").checkout()
|
32
|
+
@local.pull()
|
33
|
+
|
34
|
+
$stdout.puts "Create '#{branch_name}' branch in local"
|
35
|
+
@local.branch(branch_name).checkout()
|
36
|
+
|
37
|
+
$stdout.puts "Exec bundle update..."
|
38
|
+
$stdout.puts `bundle update`
|
39
|
+
$stdout.puts "bundle update Done."
|
40
|
+
$stdout.puts
|
41
|
+
$stdout.puts "Commit as '#{commit_message}'"
|
42
|
+
@local.add(["Gemfile", "Gemfile.lock"])
|
43
|
+
@local.commit(commit_message)
|
44
|
+
|
45
|
+
$stdout.print "Push '#{branch_name}' to origin ? (Ctrl-C for Cancel) :"
|
46
|
+
$stdin.gets
|
47
|
+
|
48
|
+
$stdout.puts "Push to remote"
|
49
|
+
@local.push("origin", branch_name)
|
50
|
+
|
51
|
+
$stdout.print "Create PR ? (Ctrl-C for Cancel) :"
|
52
|
+
$stdin.gets
|
53
|
+
|
54
|
+
$stdout.puts "Create PR"
|
55
|
+
pr = @remote.create_pull_request(@repo_name, "master", branch_name, pr_title, @pr_body)
|
56
|
+
|
57
|
+
$stdout.puts "#{pr[:html_url]} was created."
|
58
|
+
|
59
|
+
run_compare_linker(pr.number)
|
60
|
+
|
61
|
+
$stdout.puts "All Done."
|
62
|
+
end
|
63
|
+
|
64
|
+
def run_compare_linker(pr_number)
|
65
|
+
# NOTE: CompareLinker requires ENV["OCTOKIT_ACCESS_TOKEN"]
|
66
|
+
# c.f. https://github.com/masutaka/compare_linker/blob/234719c8e679fa59afa767fd149d2ca7ee51e5d3/lib/compare_linker.rb#L18
|
67
|
+
ENV["OCTOKIT_ACCESS_TOKEN"] = @token
|
68
|
+
|
69
|
+
$stdout.print "Run compare-linker for '#{@repo_name}##{pr_number}' (Ctrl-C for Cancel) :"
|
70
|
+
$stdin.gets
|
71
|
+
|
72
|
+
compare_linker = CompareLinker.new(@repo_name, pr_number)
|
73
|
+
compare_linker.formatter = CompareLinker::Formatter::Markdown.new
|
74
|
+
comment = compare_linker.make_compare_links.to_a.join("\n")
|
75
|
+
compare_linker.add_comment(@repo_name, pr_number, comment)
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
require "optparse"
|
2
|
+
require "compare_linker_command/version"
|
3
|
+
|
4
|
+
module CompareLinkerCommand
|
5
|
+
class Parser
|
6
|
+
def self.parse(*args)
|
7
|
+
self.new.parse(*args)
|
8
|
+
end
|
9
|
+
|
10
|
+
def initialize
|
11
|
+
@op = OptionParser.new
|
12
|
+
@op.program_name = "create_pr_with_compare_linker"
|
13
|
+
@op.version = VERSION
|
14
|
+
end
|
15
|
+
|
16
|
+
def parse(argv)
|
17
|
+
params = {succeeded: true}
|
18
|
+
|
19
|
+
@op.on("", "--github-access-token TOKEN", "GitHub token for access") do |v|
|
20
|
+
params[:token] = v
|
21
|
+
end
|
22
|
+
|
23
|
+
@op.on("", "--repo-name NAME", "org/repository for bundle update") do |v|
|
24
|
+
params[:repo_name] = v
|
25
|
+
end
|
26
|
+
|
27
|
+
@op.on("", "--pr-body-file [FILEPATH]", "file path of description for bundle update PR (default: empty file)") do |v|
|
28
|
+
params[:pr_body_file] = v
|
29
|
+
end
|
30
|
+
|
31
|
+
@op.on("", "--pr-number [number]", "PR number. When this option is specified, this command runs compare-linker only.") do |v|
|
32
|
+
params[:pr_number] = v.to_s.gsub(/^#/, "")
|
33
|
+
end
|
34
|
+
|
35
|
+
error_message = ""
|
36
|
+
|
37
|
+
begin
|
38
|
+
@op.parse(argv)
|
39
|
+
rescue OptionParser::InvalidOption => e
|
40
|
+
error_message << e.message
|
41
|
+
end
|
42
|
+
|
43
|
+
unless params[:token]
|
44
|
+
error_message << "--github-access-token is required. Abort.\n\n"
|
45
|
+
end
|
46
|
+
|
47
|
+
unless params[:repo_name]
|
48
|
+
error_message << "--repo-name is required. Abort.\n"
|
49
|
+
end
|
50
|
+
|
51
|
+
unless error_message.empty?
|
52
|
+
$stderr.puts error_message
|
53
|
+
$stderr.puts @op
|
54
|
+
|
55
|
+
params[:succeeded] = false
|
56
|
+
end
|
57
|
+
|
58
|
+
params
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
metadata
ADDED
@@ -0,0 +1,130 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: compare_linker_command
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- yoshihara
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-05-07 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: git
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 1.3.0
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 1.3.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: octokit
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 4.7.0
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 4.7.0
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: compare_linker
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 1.3.8
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 1.3.8
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: bundler
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '1.11'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '1.11'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rake
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '10.0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '10.0'
|
83
|
+
description: compare linker command
|
84
|
+
email:
|
85
|
+
- yshr04hrk@gmail.com
|
86
|
+
executables:
|
87
|
+
- create_pr_with_compare_linker
|
88
|
+
extensions: []
|
89
|
+
extra_rdoc_files: []
|
90
|
+
files:
|
91
|
+
- ".gitignore"
|
92
|
+
- ".ruby-version"
|
93
|
+
- CODE_OF_CONDUCT.md
|
94
|
+
- Gemfile
|
95
|
+
- LICENSE.txt
|
96
|
+
- README.md
|
97
|
+
- Rakefile
|
98
|
+
- bin/console
|
99
|
+
- bin/setup
|
100
|
+
- compare_linker_command.gemspec
|
101
|
+
- exe/create_pr_with_compare_linker
|
102
|
+
- lib/compare_linker_command.rb
|
103
|
+
- lib/compare_linker_command/executor.rb
|
104
|
+
- lib/compare_linker_command/parser.rb
|
105
|
+
- lib/compare_linker_command/version.rb
|
106
|
+
homepage: https://github.com/yoshihara/compare_linker_command
|
107
|
+
licenses:
|
108
|
+
- MIT
|
109
|
+
metadata: {}
|
110
|
+
post_install_message:
|
111
|
+
rdoc_options: []
|
112
|
+
require_paths:
|
113
|
+
- lib
|
114
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
115
|
+
requirements:
|
116
|
+
- - ">="
|
117
|
+
- !ruby/object:Gem::Version
|
118
|
+
version: '0'
|
119
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
120
|
+
requirements:
|
121
|
+
- - ">="
|
122
|
+
- !ruby/object:Gem::Version
|
123
|
+
version: '0'
|
124
|
+
requirements: []
|
125
|
+
rubyforge_project:
|
126
|
+
rubygems_version: 2.6.14
|
127
|
+
signing_key:
|
128
|
+
specification_version: 4
|
129
|
+
summary: compare linker command
|
130
|
+
test_files: []
|