github-copywriter 0.1.1 → 1.0.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: 28edcf28a7ba50ed82f9abe685af12fc4da9da92
4
- data.tar.gz: ab8737a3e5db04074640029084f557b706ad05b4
3
+ metadata.gz: b79d424345573ffe8851dfb335c047fba06fb4b6
4
+ data.tar.gz: e020289adb77957df72fb01edfac8b234c371221
5
5
  SHA512:
6
- metadata.gz: 92201c3e9cb8988113b394a17fbf96e8c40865fddb1961dce9451be45c0bf0358296d5ba8a3e6ad29197bb518bdedf162b8bfd084194965f05b703374e3ef332
7
- data.tar.gz: a6f1efaee70f5451706d3d663daa74bf7f159b743650520b31a89ea37c424cd8a8d8109628ae75dc840100c87ed923cd135cdc948cfcd9440a3144680f357e7a
6
+ metadata.gz: c5fd10fc2d7f4b457144b971e4c1f2e028f9bb663a38dc7eab49de36b26f18d1704b33afc303ef91dafe1bd49168a5e92053328c396497fbe4e348912ef56bd4
7
+ data.tar.gz: 3160dff21ba4c318f1f89afe372286e6da16237a2700660020b041851fcac12a6223fd536aaeb3a2bbb060b7dd10c838da87256063b019df738691e0324c3393
data/README.md CHANGED
@@ -6,18 +6,25 @@ Updates your copyrights... so you don't have to!
6
6
 
7
7
  `$ gem install github-copywriter`
8
8
 
9
+ ## Basic Usage
10
+
9
11
  ### Update specific repos
10
12
  `$ github-copywriter MyCoolRepo MyOtherCoolRepo`
11
13
 
12
14
  ### Update all repos
13
15
  `$ github-copywriter --all`
14
16
 
17
+ ## Other Usage
18
+
15
19
  ### Update all repos, excluding forks
16
20
  `$ github-copywriter --all --skip-forks`
17
21
 
18
22
  ### Update all repos to 2015
19
23
  `$ github-copywriter --all --year 2015`
20
24
 
25
+ ### Update only branches: gh-pages and dev
26
+ `$ github-copywriter --branches gh-pages,dev MyRepo`
27
+
21
28
  ## Contributing
22
29
  Please submit issues or feature requests [here](//github.com/ryanmjacobs/github-copywriter/issues).
23
30
  Questions and comments are welcome as well. Checkout
@@ -24,15 +24,11 @@ Usage: #{executable_name} [repos...]
24
24
 
25
25
  EOS
26
26
 
27
- opts.on("-a", "--all", "Update copyrights on ALL repositories.") do
28
- options[:all] = true
27
+ opts.on("-a", "--all", "Update ALL repositories.") do
28
+ options[:all_repos] = true
29
29
  end
30
30
 
31
- opts.on("-s", "--skip-forks", "Don't update forked repositories.") do
32
- options[:skip_forks] = true
33
- end
34
-
35
- opts.on("-y", "--year YEAR", "Update copyrights to a give year.") do |year|
31
+ opts.on("-y", "--year YEAR", "Update copyrights to a given year.") do |year|
36
32
  if year.to_i >= 1000 && year.to_i <= 9999 then
37
33
  options[:year] = year
38
34
  else
@@ -41,12 +37,12 @@ Usage: #{executable_name} [repos...]
41
37
  end
42
38
  end
43
39
 
44
- opts.on("-b", "--branches branch1,branch2", "Update specific branches.") do |comma_separated_branches|
45
- options[:branches] = comma_separated_branches.split(",").map(&:strip)
40
+ opts.on("-s", "--skip-forks", "Don't update forked repos.") do
41
+ options[:skip_forks] = true
46
42
  end
47
43
 
48
- opts.on("--all-branches", "Update all branches.") do
49
- options[:all_branches] = true
44
+ opts.on("-b", "--branches branch1,branch2", "Update specific branches only.") do |comma_separated_branches|
45
+ options[:branches] = comma_separated_branches.split(",").map(&:strip)
50
46
  end
51
47
 
52
48
  opts.on_tail("-h","--help", "Show this message.") do
@@ -61,7 +57,7 @@ Usage: #{executable_name} [repos...]
61
57
  end.parse!
62
58
 
63
59
  # Must have at least one repo!
64
- if ARGV.empty? and not options[:all]
60
+ if ARGV.empty? and not options[:all_repos]
65
61
  puts "error: No repositories supplied!".red
66
62
  exit
67
63
  end
@@ -8,6 +8,6 @@ class Copywriter
8
8
 
9
9
  # Current version
10
10
  # @return [String]
11
- VERSION = "0.1.1".freeze
11
+ VERSION = "1.0.0".freeze
12
12
 
13
13
  end
@@ -15,7 +15,7 @@ require "colorize"
15
15
 
16
16
  class Copywriter
17
17
 
18
- COMMIT_MSG = "Update copyright. ♥ github-copywriter\nFor more info, visit http://ryanmjacobs.github.io/github-copywriter"
18
+ COMMIT_MSG = "Update copyright. ♥ github-copywriter\n\nFor more info, visit http://ryanmjacobs.github.io/github-copywriter"
19
19
 
20
20
  def initialize(username, password)
21
21
  # Auth to GitHub
@@ -25,7 +25,10 @@ class Copywriter
25
25
  begin
26
26
  @client.authorizations
27
27
  rescue Octokit::Unauthorized
28
- puts "error: Bad credentials".red
28
+ puts "error: Bad credentials.".red
29
+ exit
30
+ rescue Faraday::ConnectionFailed
31
+ puts "error: Connection failed.".red
29
32
  exit
30
33
  end
31
34
  end
@@ -33,14 +36,13 @@ class Copywriter
33
36
  def run!(options={})
34
37
  # Default options
35
38
  options = {
36
- all: false,
39
+ all_repos: false,
37
40
  skip_forks: false,
38
41
  year: nil,
39
- branches: nil,
40
- all_branches: false
42
+ branches: nil
41
43
  }.merge(options)
42
44
 
43
- if options[:all] then
45
+ if options[:all_repos] then
44
46
  repos = @client.repositories()
45
47
  else
46
48
  repos = Array.new
@@ -69,16 +71,12 @@ class Copywriter
69
71
  puts "\n#{repo_name}:".cyan
70
72
 
71
73
  # Repo refs (branches) to loop through
72
- if options[:branches] != nil then
73
- refs = options[:branches].map { |branch| "heads/#{branch}" }
74
- else
75
- refs = "heads/#{repo[:default_branch]}"
76
- end
77
-
78
- # Use all branches if we have the flag
79
- if options[:all_branches] then
80
- # Get all refs of type "heads"; remove leading "refs/"
74
+ if options[:branches] == nil then
75
+ # Get every single ref (branch) by default
81
76
  refs = @client.refs(repo_name, "heads").map { |r| r[:ref].sub("refs/", "") }
77
+ else
78
+ # User-supplied branches
79
+ refs = options[:branches].map { |branch| "heads/#{branch}" }
82
80
  end
83
81
 
84
82
  # Loop through each ref
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: github-copywriter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Jacobs