neetob 0.2.1 → 0.2.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +15 -0
- data/Gemfile.lock +1 -1
- data/README.md +17 -10
- data/lib/neetob/cli/base.rb +1 -1
- data/lib/neetob/cli/fetchorupdate_repos/execute.rb +1 -1
- data/lib/neetob/cli/github/base.rb +3 -3
- data/lib/neetob/cli/github/commands.rb +5 -5
- data/lib/neetob/cli/github/gems/release.rb +3 -3
- data/lib/neetob/cli/github/issues/commands.rb +5 -5
- data/lib/neetob/cli/github/issues/create.rb +7 -7
- data/lib/neetob/cli/github/issues/list.rb +15 -15
- data/lib/neetob/cli/github/labels/commands.rb +9 -9
- data/lib/neetob/cli/github/labels/delete.rb +10 -10
- data/lib/neetob/cli/github/labels/delete_all.rb +11 -11
- data/lib/neetob/cli/github/labels/list.rb +8 -8
- data/lib/neetob/cli/github/labels/show.rb +8 -8
- data/lib/neetob/cli/github/labels/update.rb +13 -11
- data/lib/neetob/cli/github/labels/upsert.rb +11 -11
- data/lib/neetob/cli/github/make_pr/base.rb +23 -23
- data/lib/neetob/cli/github/make_pr/commands.rb +5 -5
- data/lib/neetob/cli/github/make_pr/compliance_fix.rb +19 -19
- data/lib/neetob/cli/github/make_pr/script.rb +16 -16
- data/lib/neetob/cli/github/protect_branch.rb +8 -8
- data/lib/neetob/cli/github/search.rb +7 -7
- data/lib/neetob/cli/heroku/access/add.rb +1 -1
- data/lib/neetob/cli/heroku/access/list.rb +1 -1
- data/lib/neetob/cli/heroku/access/remove.rb +1 -1
- data/lib/neetob/cli/heroku/config_vars/audit.rb +1 -1
- data/lib/neetob/cli/heroku/config_vars/list.rb +1 -1
- data/lib/neetob/cli/heroku/config_vars/remove.rb +1 -1
- data/lib/neetob/cli/heroku/config_vars/upsert.rb +1 -1
- data/lib/neetob/cli/heroku/execute.rb +1 -1
- data/lib/neetob/cli/local/ls.rb +1 -1
- data/lib/neetob/cli/users/audit.rb +1 -1
- data/lib/neetob/cli/users/commits.rb +1 -1
- data/lib/neetob/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ab7271fb7040070268b0c67e53a7dfabae013e6294265f19fc5f38de85952075
|
4
|
+
data.tar.gz: cee7a555e9d0a17f7006aefb26932cbd70d44297f2f0c13b59dde2a787f9f4f4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 07b0a97173101a0f6a67f632641c7e67f2b42155177704fa3efeefa015ca9f269b372308cc0b1503e37931158ae178625e5e3c6f2361da5f234aa9f0c90bbd25
|
7
|
+
data.tar.gz: 3cdae7098530aeaf351b82e7b31944e606bf086235fd9964842f1ad19cc59276ed10fb1130c4647a86770c326b670121e37574e25397aecba8ec4345eb290bb8
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,20 @@
|
|
1
1
|
## [Unreleased]
|
2
2
|
|
3
|
+
### [0.2.3](https://www.github.com/bigbinary/neetob/compare/v0.2.2...v0.2.3) (2023-03-10)
|
4
|
+
|
5
|
+
|
6
|
+
### Bug Fixes
|
7
|
+
|
8
|
+
* Fixed github commands to accept "--repos" arguement instead of "--apps" ([#208](https://www.github.com/bigbinary/neetob/issues/208)) ([a1b419e](https://www.github.com/bigbinary/neetob/commit/a1b419ed4e7cb902962dacfbdd7a7112f84ade4e))
|
9
|
+
|
10
|
+
### [0.2.2](https://www.github.com/bigbinary/neetob/compare/v0.2.1...v0.2.2) (2023-03-06)
|
11
|
+
|
12
|
+
|
13
|
+
### Bug Fixes
|
14
|
+
|
15
|
+
* Fixed update label command to ignore repos that doesn't have the specified label. ([#199](https://www.github.com/bigbinary/neetob/issues/199)) ([bc98c0d](https://www.github.com/bigbinary/neetob/commit/bc98c0dbd3691e66b8e2c161788f3f3a6ff6b977))
|
16
|
+
* Updated docs for gem release ([#204](https://www.github.com/bigbinary/neetob/issues/204)) ([1a93745](https://www.github.com/bigbinary/neetob/commit/1a937450b7a49f81c0e45ad7ca235ffe66a0a1e2))
|
17
|
+
|
3
18
|
### [0.2.1](https://www.github.com/bigbinary/neetob/compare/v0.2.0...v0.2.1) (2023-03-06)
|
4
19
|
|
5
20
|
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -7,6 +7,7 @@ The `neetob` gem gives different commands for interacting with Github repos, Her
|
|
7
7
|
1. [Usage](#usage)
|
8
8
|
1. [Installing neetob for use](#installing-neetob-for-use)
|
9
9
|
2. [For development](#for-development)
|
10
|
+
3. [Gem release](#gem-release)
|
10
11
|
2. [Source of truth](#source-of-truth)
|
11
12
|
3. [Working with GitHub](#working-with-github)
|
12
13
|
1. [Issues](#issues)
|
@@ -58,6 +59,7 @@ Options:
|
|
58
59
|
|
59
60
|
| Option | Meaning |
|
60
61
|
| ------------ | --------------------------------- |
|
62
|
+
| --repos | Target repo names |
|
61
63
|
| --apps | Target app names |
|
62
64
|
| --sandbox | Sandbox mode |
|
63
65
|
| --no-sandbox | Non-Sandbox mode |
|
@@ -115,6 +117,11 @@ For example:
|
|
115
117
|
|
116
118
|
![Commit message update](images/commit-message-update.png)
|
117
119
|
|
120
|
+
|
121
|
+
### Gem release
|
122
|
+
|
123
|
+
When a commit is added to the `main` branch [release](.github/workflows/release.yml) Github action checks that commit for the [conventional commit message](#conventional-commit-messages). If a proper suffix like `fix:`, `feat:`, etc is used in that commit message then the Github action will create a new PR with the updated version and changelog. The version and changelog for the `neetob` gem are updated automatically by the Github action using the commit message. When we merge this newly created PR by the Github action into the main branch, an updated Gem is released to the [rubygems](https://rubygems.org).
|
124
|
+
|
118
125
|
## Source of truth
|
119
126
|
|
120
127
|
This [list of repos](https://github.com/bigbinary/neeto-compliance/blob/main/data/neeto_repos.json) is used as the "source of truth".
|
@@ -151,11 +158,11 @@ neetob github help
|
|
151
158
|
|
152
159
|
```sh
|
153
160
|
# Lists and counts all the open issues that are currently unassigned
|
154
|
-
neetob github issues list --count --state open --assignee none --
|
161
|
+
neetob github issues list --count --state open --assignee none --repos "neeto-*-staging"
|
155
162
|
|
156
163
|
# Lists, counts and filters all unassigned open issues that are labeled as "bug"
|
157
164
|
neetob github issues list --count --label bug --state open --assignee none \
|
158
|
-
--
|
165
|
+
--repos "neeto-*-staging"
|
159
166
|
```
|
160
167
|
|
161
168
|
### Labels
|
@@ -164,10 +171,10 @@ The `labels` command provides an interface for interacting with Github labels.
|
|
164
171
|
|
165
172
|
```sh
|
166
173
|
# Lists the details of all the labels in the Github repo
|
167
|
-
neetob github labels list --
|
174
|
+
neetob github labels list --repos "neeto-*-staging"
|
168
175
|
|
169
176
|
# Provides the details for a specific label in the Github repo
|
170
|
-
neetob github labels show --name priority --
|
177
|
+
neetob github labels show --name priority --repos "neeto-*-staging"
|
171
178
|
|
172
179
|
# Changes the name of the label
|
173
180
|
neetob github labels update --old-name "High Priority" --new-name \
|
@@ -177,7 +184,7 @@ neetob github labels update --old-name "High Priority" --new-name \
|
|
177
184
|
neetob github labels upsert --all-neeto-repos
|
178
185
|
|
179
186
|
# Accepts a different JSON file using `path` option
|
180
|
-
neetob github labels upsert --path ~/Desktop/labels.json --
|
187
|
+
neetob github labels upsert --path ~/Desktop/labels.json --repos "neeto-*-staging"
|
181
188
|
|
182
189
|
# Upsert a single label using `name`, `color`, and `description` options
|
183
190
|
# No `#` is required while adding `color`
|
@@ -186,10 +193,10 @@ neetob github labels upsert --name UI --color 8250df --description \
|
|
186
193
|
|
187
194
|
# Deletes the given labels from the Github repos
|
188
195
|
neetob github labels delete --labels "High Priority" "Priority 1" "bug" \
|
189
|
-
--
|
196
|
+
--repos "neeto-*-staging"
|
190
197
|
|
191
198
|
# Deletes all the labels from the Github repos
|
192
|
-
neetob github labels delete_all --
|
199
|
+
neetob github labels delete_all --repos "neeto-*-staging"
|
193
200
|
```
|
194
201
|
|
195
202
|
Check out the default labels [file](data/github-labels.json) for the required JSON file structure.
|
@@ -210,7 +217,7 @@ Don't use `#` before the color code.
|
|
210
217
|
Searches for keywords across multiple neeto projects within specified files by utilizing the `search` command.
|
211
218
|
|
212
219
|
```sh
|
213
|
-
neetob github search --keyword neeto --path README.md --
|
220
|
+
neetob github search --keyword neeto --path README.md --repos "neeto-*-staging"
|
214
221
|
```
|
215
222
|
|
216
223
|
### Protect branch
|
@@ -218,7 +225,7 @@ neetob github search --keyword neeto --path README.md --apps "neeto-*-staging"
|
|
218
225
|
Updates branch protection rules in neeto repos by using the `protect_branch` command.
|
219
226
|
|
220
227
|
```sh
|
221
|
-
neetob github protect_branch --branch main --
|
228
|
+
neetob github protect_branch --branch main --repos "neeto-*-staging"
|
222
229
|
```
|
223
230
|
|
224
231
|
By default, file "data/branch-protection-rules.json" will be used for updating the branch protection rules.
|
@@ -238,7 +245,7 @@ To update the above-mentioned branch protection rules for the `main` branch of a
|
|
238
245
|
|
239
246
|
```sh
|
240
247
|
neetob github protect_branch --branch main --path ~/Desktop/branch-protection-rules.json \
|
241
|
-
--
|
248
|
+
--repos "neeto-*-staging"
|
242
249
|
```
|
243
250
|
|
244
251
|
We can also use the `--all-neeto-repos` option with the above mentioned command so that the
|
data/lib/neetob/cli/base.rb
CHANGED
@@ -19,7 +19,7 @@ module Neetob
|
|
19
19
|
|
20
20
|
private
|
21
21
|
|
22
|
-
def
|
22
|
+
def find_all_matching_apps_or_repos(apps, platform_name, sandbox_mode, quiet = false, all_neeto_repos = false)
|
23
23
|
inform_about_current_working_mode(sandbox_mode, quiet)
|
24
24
|
all_available_apps = sandbox_mode ?
|
25
25
|
testing_apps(platform_name) :
|
@@ -16,7 +16,7 @@ module Neetob
|
|
16
16
|
end
|
17
17
|
|
18
18
|
def run
|
19
|
-
neeto_apps =
|
19
|
+
neeto_apps = find_all_matching_apps_or_repos(apps, :github, sandbox, false, all_neeto_repos)
|
20
20
|
neeto_apps.each do |app|
|
21
21
|
app_name = app.split("/").last
|
22
22
|
ui.info("\nWorking on #{app_name}\n")
|
@@ -23,9 +23,9 @@ module Neetob
|
|
23
23
|
@client = Octokit::Client.new(access_token: auth_client.access_token)
|
24
24
|
end
|
25
25
|
|
26
|
-
def check_for_apps_and_all_neeto_repos_option(
|
27
|
-
if (
|
28
|
-
ui.error("Please provide either \"
|
26
|
+
def check_for_apps_and_all_neeto_repos_option(repos, all_neeto_repos)
|
27
|
+
if (repos.nil? && !all_neeto_repos) || (!repos.nil? && all_neeto_repos)
|
28
|
+
ui.error("Please provide either \"repos\" or \"all-neeto-repos\" option.")
|
29
29
|
exit
|
30
30
|
end
|
31
31
|
end
|
@@ -25,13 +25,13 @@ module Neetob
|
|
25
25
|
desc "gems", "Interact with the neeto gems"
|
26
26
|
subcommand "gems", Gems::Commands
|
27
27
|
|
28
|
-
desc "search", "Find the lines matching the given keyword in the specified file across all the neeto
|
29
|
-
option :
|
28
|
+
desc "search", "Find the lines matching the given keyword in the specified file across all the neeto repos"
|
29
|
+
option :repos, type: :array, aliases: "-r", required: true, desc: "Github repo names. Can be matched using the '*' wildcard. Example: \"neeto*\" \"neeto-cal-web\""
|
30
30
|
option :keyword, type: :string, aliases: "-k", desc: "Keyword which needs to be searched", required: true
|
31
31
|
option :path, type: :string, aliases: "-p",
|
32
32
|
desc: "Path of the file in which you want to search the given keyword.", required: true
|
33
33
|
def search
|
34
|
-
Search.new(options[:
|
34
|
+
Search.new(options[:repos], options[:keyword], options[:path], options[:sandbox]).run
|
35
35
|
end
|
36
36
|
|
37
37
|
desc "login", "Update the Github access token by authenticating via browser"
|
@@ -44,12 +44,12 @@ module Neetob
|
|
44
44
|
desc: "Name of the branch whose protections rules needs to be updated", required: true
|
45
45
|
option :path, type: :string, aliases: "-p",
|
46
46
|
desc: "The JSON file path which specify all the required rules for branch protection"
|
47
|
-
option :
|
47
|
+
option :repos, type: :array, aliases: "-r", desc: "Github repo names. Can be matched using the '*' wildcard. Example: \"neeto*\" \"neeto-cal-web\""
|
48
48
|
option :all_neeto_repos, type: :boolean, aliases: "--all",
|
49
49
|
desc: "Use this flag for working with all neeto repos", default: false
|
50
50
|
def protect_branch
|
51
51
|
ProtectBranch.new(
|
52
|
-
options[:branch], options[:
|
52
|
+
options[:branch], options[:repos], options[:path], options[:sandbox],
|
53
53
|
options[:all_neeto_repos]).run
|
54
54
|
end
|
55
55
|
end
|
@@ -23,7 +23,7 @@ module Neetob
|
|
23
23
|
matching_gems.each do |gem|
|
24
24
|
ui.info("\nWorking on #{gem}\n")
|
25
25
|
begin
|
26
|
-
|
26
|
+
clone_repo_in_tmp_dir("bigbinary/#{gem}")
|
27
27
|
build_gem(gem)
|
28
28
|
release_gem(gem)
|
29
29
|
if $?.success?
|
@@ -39,11 +39,11 @@ module Neetob
|
|
39
39
|
private
|
40
40
|
|
41
41
|
def build_gem(gem)
|
42
|
-
ui.info(`#{
|
42
|
+
ui.info(`#{cd_to_repo_in_tmp_dir(gem)} && gem build`)
|
43
43
|
end
|
44
44
|
|
45
45
|
def release_gem(gem)
|
46
|
-
ui.info(`#{
|
46
|
+
ui.info(`#{cd_to_repo_in_tmp_dir(gem)} && fury push #{gem}-*.gem --as unnitallman`)
|
47
47
|
end
|
48
48
|
end
|
49
49
|
end
|
@@ -11,10 +11,10 @@ module Neetob
|
|
11
11
|
module Github
|
12
12
|
module Issues
|
13
13
|
class Commands < SubCommandBase
|
14
|
-
class_option :
|
14
|
+
class_option :repos,
|
15
15
|
{
|
16
|
-
type: :array, aliases: "-
|
17
|
-
desc: "Github
|
16
|
+
type: :array, aliases: "-r", required: true,
|
17
|
+
desc: "Github repo names. Can be matched using the '*' wildcard. Example: \"neeto*\" \"neeto-cal-web\""
|
18
18
|
}
|
19
19
|
|
20
20
|
desc "list", "List the issues in the Github repos"
|
@@ -25,7 +25,7 @@ module Neetob
|
|
25
25
|
option :search, type: :string, desc: "Can provide custom query to filter or sort issues. Example: \"created:2022-11-07..2022-11-08 sort:comments-asc\""
|
26
26
|
def list
|
27
27
|
List.new(
|
28
|
-
options[:
|
28
|
+
options[:repos], options[:assignee], options[:state], options[:search], options[:count],
|
29
29
|
options[:label], options[:sandbox]).run
|
30
30
|
end
|
31
31
|
|
@@ -36,7 +36,7 @@ module Neetob
|
|
36
36
|
option :labels, type: :string, desc: "List of comma separated labels you want to add in this issue. Example: \"--labels bug,ui\""
|
37
37
|
def create
|
38
38
|
Create.new(
|
39
|
-
options[:
|
39
|
+
options[:repos],
|
40
40
|
options[:title],
|
41
41
|
options[:description],
|
42
42
|
options[:assignee],
|
@@ -9,12 +9,12 @@ module Neetob
|
|
9
9
|
module Github
|
10
10
|
module Issues
|
11
11
|
class Create < Base
|
12
|
-
attr_accessor :
|
12
|
+
attr_accessor :repos, :issue_title, :issue_description, :issue_assignee, :issue_labels, :sandbox
|
13
13
|
|
14
|
-
def initialize(
|
14
|
+
def initialize(repos, issue_title, issue_description = "", issue_assignee = "", issue_labels = "",
|
15
15
|
sandbox = false)
|
16
16
|
super()
|
17
|
-
@
|
17
|
+
@repos = repos
|
18
18
|
@issue_title = issue_title
|
19
19
|
@issue_description = issue_description
|
20
20
|
@issue_assignee = issue_assignee
|
@@ -23,12 +23,12 @@ sandbox = false)
|
|
23
23
|
end
|
24
24
|
|
25
25
|
def run
|
26
|
-
|
27
|
-
|
28
|
-
ui.info("\n Creating issue in \"#{
|
26
|
+
matching_repos = find_all_matching_apps_or_repos(repos, :github, sandbox)
|
27
|
+
matching_repos.each do |repo|
|
28
|
+
ui.info("\n Creating issue in \"#{repo}\" \n")
|
29
29
|
begin
|
30
30
|
issue_options = { assignee: issue_assignee, labels: issue_labels }
|
31
|
-
issue = client.create_issue(
|
31
|
+
issue = client.create_issue(repo, issue_title, issue_description, issue_options)
|
32
32
|
ui.success("Created the issue successfully \nLink: #{issue[:html_url]}")
|
33
33
|
rescue StandardError => e
|
34
34
|
ExceptionHandler.new(e).process
|
@@ -12,14 +12,14 @@ module Neetob
|
|
12
12
|
class List < Base
|
13
13
|
include ActionView::Helpers::DateHelper
|
14
14
|
|
15
|
-
attr_accessor :
|
15
|
+
attr_accessor :repos, :issue_state, :issue_assignee, :issue_search_query, :show_issues_count, :issue_label,
|
16
16
|
:sandbox
|
17
17
|
|
18
|
-
def initialize(
|
18
|
+
def initialize(repos, issue_assignee = "", issue_state = "open",
|
19
19
|
issue_search_query = "", show_issues_count = false, issue_label = "",
|
20
20
|
sandbox = false)
|
21
21
|
super()
|
22
|
-
@
|
22
|
+
@repos = repos
|
23
23
|
@issue_state = issue_state
|
24
24
|
@issue_assignee = issue_assignee
|
25
25
|
@show_issues_count = show_issues_count
|
@@ -29,11 +29,11 @@ module Neetob
|
|
29
29
|
end
|
30
30
|
|
31
31
|
def run
|
32
|
-
|
33
|
-
|
34
|
-
ui.info("\n Issues of #{
|
32
|
+
matching_repos = find_all_matching_apps_or_repos(repos, :github, sandbox)
|
33
|
+
matching_repos.each do |repo|
|
34
|
+
ui.info("\n Issues of #{repo} \n")
|
35
35
|
begin
|
36
|
-
issues = client.search_issues(uri_with_query_options(
|
36
|
+
issues = client.search_issues(uri_with_query_options(repo))
|
37
37
|
ui.info("There are #{issues[:total_count]} issues with matching query") if show_issues_count
|
38
38
|
table_rows = create_table(issues[:items])
|
39
39
|
table = Terminal::Table.new headings: table_columns, rows: table_rows
|
@@ -64,10 +64,10 @@ module Neetob
|
|
64
64
|
end
|
65
65
|
end
|
66
66
|
|
67
|
-
def uri_with_query_options(
|
68
|
-
uri = "repo:#{
|
67
|
+
def uri_with_query_options(repo)
|
68
|
+
uri = "repo:#{repo} is:issue state:#{issue_state}"
|
69
69
|
unless issue_label.nil?
|
70
|
-
check_valid_labels(
|
70
|
+
check_valid_labels(repo)
|
71
71
|
uri.concat(" label:#{issue_label}")
|
72
72
|
end
|
73
73
|
uri.concat(issue_assignee == "none" ? " no:assignee" : " assignee:#{issue_assignee}") if issue_assignee
|
@@ -78,14 +78,14 @@ module Neetob
|
|
78
78
|
labels.map { |label| label[:name] }.join(", ")
|
79
79
|
end
|
80
80
|
|
81
|
-
def check_valid_labels(
|
82
|
-
issue_label.split(",").each { |label| valid_label?(
|
81
|
+
def check_valid_labels(repo)
|
82
|
+
issue_label.split(",").each { |label| valid_label?(repo, label) }
|
83
83
|
end
|
84
84
|
|
85
|
-
def valid_label?(
|
86
|
-
client.label(
|
85
|
+
def valid_label?(repo, label)
|
86
|
+
client.label(repo, label)
|
87
87
|
rescue Octokit::NotFound => e
|
88
|
-
ui.error("There is no \"#{label}\" label in the \"#{
|
88
|
+
ui.error("There is no \"#{label}\" label in the \"#{repo}\" repo.")
|
89
89
|
end
|
90
90
|
end
|
91
91
|
end
|
@@ -15,22 +15,22 @@ module Neetob
|
|
15
15
|
module Github
|
16
16
|
module Labels
|
17
17
|
class Commands < SubCommandBase
|
18
|
-
class_option :
|
19
|
-
type: :array, aliases: "-
|
20
|
-
desc: "Github
|
18
|
+
class_option :repos,
|
19
|
+
type: :array, aliases: "-r",
|
20
|
+
desc: "Github repo names. Can be matched using the '*' wildcard. Example: \"neeto*\" \"neeto-cal-web\""
|
21
21
|
class_option :all_neeto_repos,
|
22
22
|
type: :boolean, aliases: "--all", default: false,
|
23
23
|
desc: "Use this flag for working with all neeto repos"
|
24
24
|
|
25
25
|
desc "list", "List all the labels in the Github repos"
|
26
26
|
def list
|
27
|
-
List.new(options[:
|
27
|
+
List.new(options[:repos], options[:sandbox], options[:all_neeto_repos]).run
|
28
28
|
end
|
29
29
|
|
30
30
|
desc "show", "Show details about the given label in the Github repos"
|
31
31
|
option :name, type: :string, aliases: "-n", required: true, desc: "Name of the label"
|
32
32
|
def show
|
33
|
-
Show.new(options[:
|
33
|
+
Show.new(options[:repos], options[:name], options[:sandbox], options[:all_neeto_repos]).run
|
34
34
|
end
|
35
35
|
|
36
36
|
desc "upsert", "Create and update labels in the Github repos"
|
@@ -40,19 +40,19 @@ module Neetob
|
|
40
40
|
option :description, type: :string, desc: "Description of the label you want to upsert"
|
41
41
|
def upsert
|
42
42
|
Upsert.new(
|
43
|
-
options[:
|
43
|
+
options[:repos], options[:path], options[:sandbox], options[:all_neeto_repos], options[:name],
|
44
44
|
options[:color], options[:description]).run
|
45
45
|
end
|
46
46
|
|
47
47
|
desc "delete_all", "Delete all the labels from the Github repos"
|
48
48
|
def delete_all
|
49
|
-
DeleteAll.new(options[:
|
49
|
+
DeleteAll.new(options[:repos], options[:sandbox], options[:all_neeto_repos]).run
|
50
50
|
end
|
51
51
|
|
52
52
|
desc "delete", "Delete some labels from the Github repos"
|
53
53
|
option :labels, type: :array, required: true, desc: "Labels you want to delete from the repos."
|
54
54
|
def delete
|
55
|
-
Delete.new(options[:
|
55
|
+
Delete.new(options[:repos], options[:labels], options[:sandbox], options[:all_neeto_repos]).run
|
56
56
|
end
|
57
57
|
|
58
58
|
desc "update", "Update a label name in Github repos"
|
@@ -60,7 +60,7 @@ module Neetob
|
|
60
60
|
option :new_name, type: :string, required: true, desc: "New name for the updated label"
|
61
61
|
def update
|
62
62
|
Update.new(
|
63
|
-
options[:
|
63
|
+
options[:repos], options[:old_name], options[:new_name], options[:sandbox],
|
64
64
|
options[:all_neeto_repos]).run
|
65
65
|
end
|
66
66
|
end
|
@@ -9,31 +9,31 @@ module Neetob
|
|
9
9
|
module Github
|
10
10
|
module Labels
|
11
11
|
class Delete < Base
|
12
|
-
attr_accessor :
|
12
|
+
attr_accessor :repos, :sandbox, :labels, :all_neeto_repos
|
13
13
|
|
14
|
-
def initialize(
|
14
|
+
def initialize(repos, labels, sandbox = false, all_neeto_repos = false)
|
15
15
|
super()
|
16
16
|
@labels = labels
|
17
|
-
@
|
17
|
+
@repos = repos
|
18
18
|
@sandbox = sandbox
|
19
19
|
@all_neeto_repos = all_neeto_repos
|
20
20
|
end
|
21
21
|
|
22
22
|
def run
|
23
|
-
check_for_apps_and_all_neeto_repos_option(
|
24
|
-
|
25
|
-
|
26
|
-
ui.info("\n Deleting labels from #{
|
23
|
+
check_for_apps_and_all_neeto_repos_option(repos, all_neeto_repos)
|
24
|
+
matching_repos = find_all_matching_apps_or_repos(repos, :github, sandbox, false, all_neeto_repos)
|
25
|
+
matching_repos.each do |repo|
|
26
|
+
ui.info("\n Deleting labels from #{repo} repo \n")
|
27
27
|
labels.each do |label|
|
28
|
-
delete_label(
|
28
|
+
delete_label(repo, label)
|
29
29
|
end
|
30
30
|
end
|
31
31
|
end
|
32
32
|
|
33
33
|
private
|
34
34
|
|
35
|
-
def delete_label(
|
36
|
-
if client.delete_label!(
|
35
|
+
def delete_label(repo, label)
|
36
|
+
if client.delete_label!(repo, label)
|
37
37
|
ui.success("The \"#{label}\" label deleted successfully")
|
38
38
|
else
|
39
39
|
ui.error("The \"#{label}\" label can't be deleted. Please check and try again")
|
@@ -9,24 +9,24 @@ module Neetob
|
|
9
9
|
module Github
|
10
10
|
module Labels
|
11
11
|
class DeleteAll < Base
|
12
|
-
attr_accessor :
|
12
|
+
attr_accessor :repos, :sandbox, :all_neeto_repos
|
13
13
|
|
14
|
-
def initialize(
|
14
|
+
def initialize(repos, sandbox = false, all_neeto_repos = false)
|
15
15
|
super()
|
16
|
-
@
|
16
|
+
@repos = repos
|
17
17
|
@sandbox = sandbox
|
18
18
|
@all_neeto_repos = all_neeto_repos
|
19
19
|
end
|
20
20
|
|
21
21
|
def run
|
22
|
-
check_for_apps_and_all_neeto_repos_option(
|
23
|
-
|
24
|
-
|
25
|
-
ui.info("\n Working on #{
|
22
|
+
check_for_apps_and_all_neeto_repos_option(repos, all_neeto_repos)
|
23
|
+
matching_repos = find_all_matching_apps_or_repos(repos, :github, sandbox, false, all_neeto_repos)
|
24
|
+
matching_repos.each do |repo|
|
25
|
+
ui.info("\n Working on #{repo} repo \n")
|
26
26
|
begin
|
27
|
-
labels = client.labels(
|
27
|
+
labels = client.labels(repo)
|
28
28
|
labels.each do |label|
|
29
|
-
delete_label(
|
29
|
+
delete_label(repo, label)
|
30
30
|
end
|
31
31
|
rescue StandardError => e
|
32
32
|
ExceptionHandler.new(e).process
|
@@ -36,8 +36,8 @@ module Neetob
|
|
36
36
|
|
37
37
|
private
|
38
38
|
|
39
|
-
def delete_label(
|
40
|
-
if client.delete_label!(
|
39
|
+
def delete_label(repo, label_details)
|
40
|
+
if client.delete_label!(repo, label_details[:name])
|
41
41
|
ui.success("The \"#{label_details[:name]}\" label deleted successfully")
|
42
42
|
else
|
43
43
|
ui.error("The \"#{label_details[:name]}\" label can't be deleted. Please try again")
|
@@ -9,22 +9,22 @@ module Neetob
|
|
9
9
|
module Github
|
10
10
|
module Labels
|
11
11
|
class List < Base
|
12
|
-
attr_accessor :
|
12
|
+
attr_accessor :repos, :sandbox, :all_neeto_repos
|
13
13
|
|
14
|
-
def initialize(
|
14
|
+
def initialize(repos, sandbox = false, all_neeto_repos = false)
|
15
15
|
super()
|
16
|
-
@
|
16
|
+
@repos = repos
|
17
17
|
@sandbox = sandbox
|
18
18
|
@all_neeto_repos = all_neeto_repos
|
19
19
|
end
|
20
20
|
|
21
21
|
def run
|
22
|
-
check_for_apps_and_all_neeto_repos_option(
|
23
|
-
|
24
|
-
|
25
|
-
ui.info("\n Labels of #{
|
22
|
+
check_for_apps_and_all_neeto_repos_option(repos, all_neeto_repos)
|
23
|
+
matching_repos = find_all_matching_apps_or_repos(repos, :github, sandbox, false, all_neeto_repos)
|
24
|
+
matching_repos.each do |repo|
|
25
|
+
ui.info("\n Labels of #{repo} \n")
|
26
26
|
begin
|
27
|
-
labels = client.labels(
|
27
|
+
labels = client.labels(repo)
|
28
28
|
ui.success(labels)
|
29
29
|
rescue StandardError => e
|
30
30
|
ExceptionHandler.new(e).process
|
@@ -9,23 +9,23 @@ module Neetob
|
|
9
9
|
module Github
|
10
10
|
module Labels
|
11
11
|
class Show < Base
|
12
|
-
attr_accessor :
|
12
|
+
attr_accessor :repos, :label_name, :sandbox, :all_neeto_repos
|
13
13
|
|
14
|
-
def initialize(
|
14
|
+
def initialize(repos, label_name, sandbox = false, all_neeto_repos = false)
|
15
15
|
super()
|
16
|
-
@
|
16
|
+
@repos = repos
|
17
17
|
@label_name = label_name
|
18
18
|
@sandbox = sandbox
|
19
19
|
@all_neeto_repos = all_neeto_repos
|
20
20
|
end
|
21
21
|
|
22
22
|
def run
|
23
|
-
check_for_apps_and_all_neeto_repos_option(
|
24
|
-
|
25
|
-
|
26
|
-
ui.info("\n \"#{label_name}\" label details from #{
|
23
|
+
check_for_apps_and_all_neeto_repos_option(repos, all_neeto_repos)
|
24
|
+
matching_repos = find_all_matching_apps_or_repos(repos, :github, sandbox, false, all_neeto_repos)
|
25
|
+
matching_repos.each do |repo|
|
26
|
+
ui.info("\n \"#{label_name}\" label details from #{repo} \n")
|
27
27
|
begin
|
28
|
-
label_details = client.label(
|
28
|
+
label_details = client.label(repo, label_name)
|
29
29
|
ui.success(label_details.inspect)
|
30
30
|
rescue StandardError => e
|
31
31
|
ExceptionHandler.new(e).process
|
@@ -9,11 +9,11 @@ module Neetob
|
|
9
9
|
module Github
|
10
10
|
module Labels
|
11
11
|
class Update < Base
|
12
|
-
attr_accessor :
|
12
|
+
attr_accessor :repos, :sandbox, :old_name, :new_name, :all_neeto_repos
|
13
13
|
|
14
|
-
def initialize(
|
14
|
+
def initialize(repos, old_name, new_name, sandbox = false, all_neeto_repos = false)
|
15
15
|
super()
|
16
|
-
@
|
16
|
+
@repos = repos
|
17
17
|
@sandbox = sandbox
|
18
18
|
@old_name = old_name
|
19
19
|
@new_name = new_name
|
@@ -21,12 +21,14 @@ module Neetob
|
|
21
21
|
end
|
22
22
|
|
23
23
|
def run
|
24
|
-
check_for_apps_and_all_neeto_repos_option(
|
25
|
-
|
26
|
-
|
27
|
-
ui.info("\
|
24
|
+
check_for_apps_and_all_neeto_repos_option(repos, all_neeto_repos)
|
25
|
+
matching_repos = find_all_matching_apps_or_repos(repos, :github, sandbox, false, all_neeto_repos)
|
26
|
+
matching_repos.each do |repo|
|
27
|
+
ui.info("\nUpdating label for #{repo} repo \n")
|
28
28
|
begin
|
29
|
-
update_label!(
|
29
|
+
update_label!(repo, old_name, new_name)
|
30
|
+
rescue Octokit::NotFound
|
31
|
+
ui.say("Ignoring update for #{repo} repo as it doesn't have the \"#{old_name}\" label.")
|
30
32
|
rescue StandardError => e
|
31
33
|
ExceptionHandler.new(e).process
|
32
34
|
end
|
@@ -35,12 +37,12 @@ module Neetob
|
|
35
37
|
|
36
38
|
private
|
37
39
|
|
38
|
-
def update_label!(
|
39
|
-
client.label(
|
40
|
+
def update_label!(repo, old_name, new_name)
|
41
|
+
client.label(repo, new_name)
|
40
42
|
ui.error("Label with name \"#{new_name}\" already exists.")
|
41
43
|
nil
|
42
44
|
rescue Octokit::NotFound
|
43
|
-
client.update_label(
|
45
|
+
client.update_label(repo, old_name, { name: new_name })
|
44
46
|
ui.success("Label \"#{old_name}\" updated to \"#{new_name}\" successfully")
|
45
47
|
rescue StandardError => e
|
46
48
|
ExceptionHandler.new(e).process
|
@@ -11,12 +11,12 @@ module Neetob
|
|
11
11
|
class Upsert < Base
|
12
12
|
WHITE_COLOR_HEX_CODE = "ffffff"
|
13
13
|
|
14
|
-
attr_accessor :
|
14
|
+
attr_accessor :repos, :required_labels_json_file_path, :sandbox, :all_neeto_repos, :name, :color, :description
|
15
15
|
|
16
|
-
def initialize(
|
16
|
+
def initialize(repos, required_labels_json_file_path = "", sandbox = false, all_neeto_repos = false,
|
17
17
|
name = "", color = "", description = "")
|
18
18
|
super()
|
19
|
-
@
|
19
|
+
@repos = repos
|
20
20
|
@required_labels_json_file_path = required_labels_json_file_path
|
21
21
|
@sandbox = sandbox
|
22
22
|
@all_neeto_repos = all_neeto_repos
|
@@ -26,15 +26,15 @@ module Neetob
|
|
26
26
|
end
|
27
27
|
|
28
28
|
def run
|
29
|
-
check_for_apps_and_all_neeto_repos_option(
|
30
|
-
|
29
|
+
check_for_apps_and_all_neeto_repos_option(repos, all_neeto_repos)
|
30
|
+
matching_repos = find_all_matching_apps_or_repos(repos, :github, sandbox, false, all_neeto_repos)
|
31
31
|
inform_about_default_labels_file
|
32
|
-
|
33
|
-
ui.info("\nWorking on #{
|
32
|
+
matching_repos.each do |repo|
|
33
|
+
ui.info("\nWorking on #{repo} repo\n")
|
34
34
|
begin
|
35
35
|
required_labels = get_required_labels
|
36
36
|
required_labels.each do |label|
|
37
|
-
create_or_update_label(
|
37
|
+
create_or_update_label(repo, label)
|
38
38
|
sleep(1)
|
39
39
|
end
|
40
40
|
rescue StandardError => e
|
@@ -68,13 +68,13 @@ module Neetob
|
|
68
68
|
]
|
69
69
|
end
|
70
70
|
|
71
|
-
def create_or_update_label(
|
71
|
+
def create_or_update_label(repo, label_details)
|
72
72
|
begin
|
73
|
-
client.update_label(
|
73
|
+
client.update_label(repo, label_details["name"], label_details)
|
74
74
|
ui.success("Label \"#{label_details["name"]}\" updated successfully")
|
75
75
|
rescue Octokit::NotFound
|
76
76
|
client.add_label(
|
77
|
-
|
77
|
+
repo, label_details["name"], label_details["color"] || WHITE_COLOR_HEX_CODE,
|
78
78
|
label_details)
|
79
79
|
ui.success("Label \"#{label_details["name"]}\" created successfully")
|
80
80
|
rescue StandardError => e
|
@@ -24,51 +24,51 @@ module Neetob
|
|
24
24
|
`mkdir /tmp/neetob`
|
25
25
|
end
|
26
26
|
|
27
|
-
def
|
28
|
-
|
27
|
+
def repo_name_without_org_suffix(repo)
|
28
|
+
repo.split("/").last
|
29
29
|
end
|
30
30
|
|
31
|
-
def
|
32
|
-
`git clone --quiet git@github.com:#{
|
31
|
+
def clone_repo_in_tmp_dir(repo)
|
32
|
+
`git clone --quiet git@github.com:#{repo}.git /tmp/neetob/#{repo_name_without_org_suffix(repo)}`
|
33
33
|
end
|
34
34
|
|
35
|
-
def add_commmit_and_push_changes(
|
36
|
-
`#{
|
35
|
+
def add_commmit_and_push_changes(repo)
|
36
|
+
`#{cd_to_repo_in_tmp_dir(repo)} && git add . && \\
|
37
37
|
git commit -m "#{pr_title}" && git push -u origin #{branch_name} --force`
|
38
38
|
end
|
39
39
|
|
40
|
-
def delete_local_feature_branch(
|
41
|
-
`#{
|
40
|
+
def delete_local_feature_branch(repo)
|
41
|
+
`#{cd_to_repo_in_tmp_dir(repo)} && git checkout main && git branch -D #{branch_name}`
|
42
42
|
end
|
43
43
|
|
44
|
-
def checkout_to_new_branch(
|
45
|
-
`#{
|
44
|
+
def checkout_to_new_branch(repo)
|
45
|
+
`#{cd_to_repo_in_tmp_dir(repo)} && git checkout -b #{branch_name}`
|
46
46
|
end
|
47
47
|
|
48
|
-
def checkout_to_feature_branch(
|
49
|
-
`#{
|
48
|
+
def checkout_to_feature_branch(repo)
|
49
|
+
`#{cd_to_repo_in_tmp_dir(repo)} && git checkout #{branch_name}`
|
50
50
|
end
|
51
51
|
|
52
|
-
def delete_remote_feature_branch(
|
53
|
-
`#{
|
52
|
+
def delete_remote_feature_branch(repo)
|
53
|
+
`#{cd_to_repo_in_tmp_dir(repo)} && git push origin --delete #{branch_name}`
|
54
54
|
end
|
55
55
|
|
56
|
-
def check_and_delete_remote_branch(
|
57
|
-
checkout_to_feature_branch(
|
56
|
+
def check_and_delete_remote_branch(repo)
|
57
|
+
checkout_to_feature_branch(repo)
|
58
58
|
if $?.success?
|
59
59
|
ui.info("Remote branch found with the name \"#{branch_name}\"")
|
60
|
-
delete_remote_feature_branch(
|
61
|
-
delete_local_feature_branch(
|
60
|
+
delete_remote_feature_branch(repo)
|
61
|
+
delete_local_feature_branch(repo)
|
62
62
|
end
|
63
|
-
checkout_to_new_branch(
|
63
|
+
checkout_to_new_branch(repo)
|
64
64
|
end
|
65
65
|
|
66
|
-
def
|
67
|
-
"cd /tmp/neetob/#{
|
66
|
+
def cd_to_repo_in_tmp_dir(repo)
|
67
|
+
"cd /tmp/neetob/#{repo_name_without_org_suffix(repo)}"
|
68
68
|
end
|
69
69
|
|
70
|
-
def add_org_suffix(
|
71
|
-
|
70
|
+
def add_org_suffix(repos)
|
71
|
+
repos.map { |repo| "bigbinary/#{repo}" }
|
72
72
|
end
|
73
73
|
end
|
74
74
|
end
|
@@ -11,14 +11,14 @@ module Neetob
|
|
11
11
|
module Github
|
12
12
|
module MakePr
|
13
13
|
class Commands < SubCommandBase
|
14
|
-
class_option :
|
15
|
-
desc: "Github
|
14
|
+
class_option :repos, type: :array, aliases: "-r", default: ["*"],
|
15
|
+
desc: "Github repo names. Can be matched using the '*' wildcard. Example: \"neeto*\" \"neeto-cal-web\""
|
16
16
|
class_option :nanos, type: :boolean, aliases: "-n", default: false,
|
17
17
|
desc: "Use this flag to make PRs for the neeto gems"
|
18
18
|
|
19
19
|
desc "compliance-fix", "Create PRs for fixing neeto compliance in all products"
|
20
20
|
def compliance_fix
|
21
|
-
ComplianceFix.new(options[:
|
21
|
+
ComplianceFix.new(options[:repos], options[:nanos], options[:sandbox]).run
|
22
22
|
end
|
23
23
|
|
24
24
|
desc "script", "Create PRs after running the given script for each product."
|
@@ -29,8 +29,8 @@ module Neetob
|
|
29
29
|
option :description, type: :string, aliases: "-d", desc: "Description of the PR"
|
30
30
|
def script
|
31
31
|
Script.new(
|
32
|
-
options[:
|
33
|
-
options[:sandbox]).run
|
32
|
+
options[:repos], options[:path], options[:title], options[:branch], options[:description],
|
33
|
+
options[:nanos], options[:sandbox]).run
|
34
34
|
end
|
35
35
|
end
|
36
36
|
end
|
@@ -9,31 +9,31 @@ module Neetob
|
|
9
9
|
module Github
|
10
10
|
module MakePr
|
11
11
|
class ComplianceFix < Base
|
12
|
-
attr_accessor :
|
12
|
+
attr_accessor :repos, :sandbox, :should_fix_nanos
|
13
13
|
|
14
|
-
def initialize(
|
14
|
+
def initialize(repos, should_fix_nanos = false, sandbox = false)
|
15
15
|
super()
|
16
|
-
@
|
16
|
+
@repos = repos
|
17
17
|
@sandbox = sandbox
|
18
18
|
@should_fix_nanos = should_fix_nanos
|
19
19
|
end
|
20
20
|
|
21
21
|
def run
|
22
|
-
|
22
|
+
matching_repos = should_fix_nanos ?
|
23
23
|
add_org_suffix(find_all_matching_gems) :
|
24
|
-
|
24
|
+
find_all_matching_apps_or_repos(repos, :github, sandbox)
|
25
25
|
delete_and_create_temp_neetob_dir
|
26
|
-
|
27
|
-
ui.info("\nWorking on #{
|
26
|
+
matching_repos.each do |repo|
|
27
|
+
ui.info("\nWorking on #{repo}\n")
|
28
28
|
begin
|
29
|
-
|
30
|
-
check_and_delete_remote_branch(
|
31
|
-
bundle_install(
|
32
|
-
fix_neeto_audit(
|
33
|
-
ui.info(add_commmit_and_push_changes(
|
34
|
-
delete_local_feature_branch(
|
35
|
-
res = client.create_pull_request(
|
36
|
-
ui.success("PR created in \"#{
|
29
|
+
clone_repo_in_tmp_dir(repo)
|
30
|
+
check_and_delete_remote_branch(repo)
|
31
|
+
bundle_install(repo)
|
32
|
+
fix_neeto_audit(repo)
|
33
|
+
ui.info(add_commmit_and_push_changes(repo))
|
34
|
+
delete_local_feature_branch(repo)
|
35
|
+
res = client.create_pull_request(repo, "main", BRANCH_NAME, PR_TITLE)
|
36
|
+
ui.success("PR created in \"#{repo}\" project successfully.")
|
37
37
|
rescue StandardError => e
|
38
38
|
ExceptionHandler.new(e).process
|
39
39
|
end
|
@@ -43,12 +43,12 @@ module Neetob
|
|
43
43
|
|
44
44
|
private
|
45
45
|
|
46
|
-
def bundle_install(
|
47
|
-
`#{
|
46
|
+
def bundle_install(repo)
|
47
|
+
`#{cd_to_repo_in_tmp_dir(repo)} && bundle install`
|
48
48
|
end
|
49
49
|
|
50
|
-
def fix_neeto_audit(
|
51
|
-
`#{
|
50
|
+
def fix_neeto_audit(repo)
|
51
|
+
`#{cd_to_repo_in_tmp_dir(repo)} && bundle exec neeto-audit -a`
|
52
52
|
end
|
53
53
|
end
|
54
54
|
end
|
@@ -9,12 +9,12 @@ module Neetob
|
|
9
9
|
module Github
|
10
10
|
module MakePr
|
11
11
|
class Script < Base
|
12
|
-
attr_accessor :
|
12
|
+
attr_accessor :repos, :sandbox, :path_to_the_script_file, :pr_description, :should_fix_nanos
|
13
13
|
|
14
|
-
def initialize(
|
14
|
+
def initialize(repos, path_to_the_script_file, pr_title,
|
15
15
|
branch_name, pr_description, should_fix_nanos, sandbox = false)
|
16
16
|
super(pr_title, branch_name)
|
17
|
-
@
|
17
|
+
@repos = repos
|
18
18
|
@sandbox = sandbox
|
19
19
|
@path_to_the_script_file = path_to_the_script_file
|
20
20
|
@pr_description = pr_description
|
@@ -22,21 +22,21 @@ module Neetob
|
|
22
22
|
end
|
23
23
|
|
24
24
|
def run
|
25
|
-
|
25
|
+
matching_repos = should_fix_nanos ?
|
26
26
|
add_org_suffix(find_all_matching_gems) :
|
27
|
-
|
27
|
+
find_all_matching_apps_or_repos(repos, :github, sandbox)
|
28
28
|
delete_and_create_temp_neetob_dir
|
29
|
-
|
30
|
-
ui.info("\n Working on #{
|
29
|
+
matching_repos.each do |repo|
|
30
|
+
ui.info("\n Working on #{repo} \n")
|
31
31
|
begin
|
32
|
-
|
33
|
-
check_and_delete_remote_branch(
|
32
|
+
clone_repo_in_tmp_dir(repo)
|
33
|
+
check_and_delete_remote_branch(repo)
|
34
34
|
update_script_file_permissions
|
35
|
-
execute_script(
|
36
|
-
ui.info(add_commmit_and_push_changes(
|
37
|
-
delete_local_feature_branch(
|
38
|
-
res = client.create_pull_request(
|
39
|
-
ui.success("PR created in \"#{
|
35
|
+
execute_script(repo)
|
36
|
+
ui.info(add_commmit_and_push_changes(repo))
|
37
|
+
delete_local_feature_branch(repo)
|
38
|
+
res = client.create_pull_request(repo, "main", branch_name, pr_title, pr_description)
|
39
|
+
ui.success("PR created in \"#{repo}\" project successfully.")
|
40
40
|
rescue StandardError => e
|
41
41
|
ExceptionHandler.new(e).process
|
42
42
|
end
|
@@ -50,8 +50,8 @@ module Neetob
|
|
50
50
|
`chmod +x #{path_to_the_script_file}`
|
51
51
|
end
|
52
52
|
|
53
|
-
def execute_script(
|
54
|
-
`#{
|
53
|
+
def execute_script(repo)
|
54
|
+
`#{cd_to_repo_in_tmp_dir(repo)} && #{path_to_the_script_file}`
|
55
55
|
end
|
56
56
|
end
|
57
57
|
end
|
@@ -6,27 +6,27 @@ module Neetob
|
|
6
6
|
class CLI
|
7
7
|
module Github
|
8
8
|
class ProtectBranch < Base
|
9
|
-
attr_accessor :branch_name, :required_rules_json_file_path, :
|
9
|
+
attr_accessor :branch_name, :required_rules_json_file_path, :repos, :sandbox, :all_neeto_repos
|
10
10
|
|
11
|
-
def initialize(branch_name,
|
11
|
+
def initialize(branch_name, repos, required_rules_json_file_path = "", sandbox = false, all_neeto_repos = false)
|
12
12
|
super()
|
13
13
|
@branch_name = branch_name
|
14
14
|
@required_rules_json_file_path = required_rules_json_file_path
|
15
|
-
@
|
15
|
+
@repos = repos
|
16
16
|
@sandbox = sandbox
|
17
17
|
@all_neeto_repos = all_neeto_repos
|
18
18
|
end
|
19
19
|
|
20
20
|
def run
|
21
|
-
check_for_apps_and_all_neeto_repos_option(
|
22
|
-
|
21
|
+
check_for_apps_and_all_neeto_repos_option(repos, all_neeto_repos)
|
22
|
+
matching_repos = find_all_matching_apps_or_repos(repos, :github, sandbox, false, all_neeto_repos)
|
23
23
|
inform_about_default_rules_file
|
24
|
-
|
25
|
-
ui.info("\n Working on \"#{
|
24
|
+
matching_repos.each do |repo|
|
25
|
+
ui.info("\n Working on \"#{repo}\" repo")
|
26
26
|
ui.info(" Updating \"#{branch_name}\" branch protection rules")
|
27
27
|
rules = read_json_file(required_rules_json_file_path || default_rules_file_path)
|
28
28
|
rules_with_symbol_keys = rules.transform_keys(&:to_sym)
|
29
|
-
client.protect_branch(
|
29
|
+
client.protect_branch(repo, branch_name, rules_with_symbol_keys)
|
30
30
|
ui.success("Branch protection rules updated successfully")
|
31
31
|
end
|
32
32
|
end
|
@@ -6,22 +6,22 @@ module Neetob
|
|
6
6
|
class CLI
|
7
7
|
module Github
|
8
8
|
class Search < Base
|
9
|
-
attr_accessor :
|
9
|
+
attr_accessor :repos, :key_to_search, :search_file_path, :sandbox
|
10
10
|
|
11
|
-
def initialize(
|
11
|
+
def initialize(repos, key_to_search, search_file_path, sandbox = false)
|
12
12
|
super()
|
13
|
-
@
|
13
|
+
@repos = repos
|
14
14
|
@key_to_search = key_to_search
|
15
15
|
@search_file_path = search_file_path
|
16
16
|
@sandbox = sandbox
|
17
17
|
end
|
18
18
|
|
19
19
|
def run
|
20
|
-
|
21
|
-
|
20
|
+
matching_repos = find_all_matching_apps_or_repos(repos, :github, sandbox)
|
21
|
+
matching_repos.each do |repo|
|
22
22
|
begin
|
23
|
-
ui.info("\n Searching in \"#{
|
24
|
-
content = Base64.decode64(client.contents(
|
23
|
+
ui.info("\n Searching in \"#{repo}/#{search_file_path}\" for \"#{key_to_search}\"\n")
|
24
|
+
content = Base64.decode64(client.contents(repo, path: search_file_path).content)
|
25
25
|
ui.error("Keyword not found") and next unless content.include? key_to_search
|
26
26
|
|
27
27
|
content.each_line do |line|
|
@@ -16,7 +16,7 @@ module Neetob
|
|
16
16
|
end
|
17
17
|
|
18
18
|
def run
|
19
|
-
matching_apps =
|
19
|
+
matching_apps = find_all_matching_apps_or_repos(apps, :heroku, sandbox)
|
20
20
|
matching_apps.each do |app|
|
21
21
|
ui.info("\n Users for \"#{app}\" app\n")
|
22
22
|
users = `heroku access -a #{app}`
|
@@ -20,7 +20,7 @@ module Neetob
|
|
20
20
|
end
|
21
21
|
|
22
22
|
def run
|
23
|
-
matching_apps =
|
23
|
+
matching_apps = find_all_matching_apps_or_repos(apps, :heroku, sandbox)
|
24
24
|
table_rows = []
|
25
25
|
expected_config = read_json_file(expected_config_vars_json_file_path || default_config_vars_json_file_path)
|
26
26
|
return unless expected_config
|
@@ -18,7 +18,7 @@ module Neetob
|
|
18
18
|
end
|
19
19
|
|
20
20
|
def run
|
21
|
-
matching_apps =
|
21
|
+
matching_apps = find_all_matching_apps_or_repos(apps, :heroku, sandbox)
|
22
22
|
matching_apps.each do |app|
|
23
23
|
ui.info("\n Config of #{app}\n")
|
24
24
|
config = `heroku config -a #{app} --json`
|
@@ -25,7 +25,7 @@ required_config_vars_with_project_keys_json_file_path, sandbox = false)
|
|
25
25
|
inform_about_current_working_mode(sandbox) if apps.nil?
|
26
26
|
apps_to_be_updated = apps.nil? ?
|
27
27
|
read_json_file(required_config_vars_with_project_keys_json_file_path) :
|
28
|
-
|
28
|
+
find_all_matching_apps_or_repos(apps, :heroku, sandbox)
|
29
29
|
inform_about_default_config_vars_file
|
30
30
|
|
31
31
|
apps_to_be_updated.each do |app|
|
@@ -17,7 +17,7 @@ module Neetob
|
|
17
17
|
end
|
18
18
|
|
19
19
|
def run
|
20
|
-
matching_apps =
|
20
|
+
matching_apps = find_all_matching_apps_or_repos(apps, :heroku, sandbox)
|
21
21
|
rails_runner_command = "rails runner '#{command_to_execute}'"
|
22
22
|
heroku_command = should_run_in_rails_console ? rails_runner_command : command_to_execute
|
23
23
|
matching_apps.each do |app|
|
data/lib/neetob/cli/local/ls.rb
CHANGED
@@ -16,7 +16,7 @@ module Neetob
|
|
16
16
|
end
|
17
17
|
|
18
18
|
def run
|
19
|
-
matching_apps =
|
19
|
+
matching_apps = find_all_matching_apps_or_repos(apps, :github, sandbox, true)
|
20
20
|
matching_apps.each do |app|
|
21
21
|
app_name = app.split("/")[1]
|
22
22
|
ui.info("\nListing files from #{app_name}/#{dir}\n")
|
@@ -27,7 +27,7 @@ module Neetob
|
|
27
27
|
private
|
28
28
|
|
29
29
|
def users_for_all_available_apps
|
30
|
-
|
30
|
+
find_all_matching_apps_or_repos(["*"], :github, sandbox, true).map do |app|
|
31
31
|
clone_repo_and_get_users(app).split("\n").map { |user| "#{user} #{app}" }
|
32
32
|
end
|
33
33
|
end
|
@@ -32,7 +32,7 @@ module Neetob
|
|
32
32
|
private
|
33
33
|
|
34
34
|
def build_commit_rows
|
35
|
-
commits =
|
35
|
+
commits = find_all_matching_apps_or_repos(apps, :github, sandbox, true, all_neeto_repos).map do |app|
|
36
36
|
commits = commits_within_range(app)
|
37
37
|
if commits&.empty?
|
38
38
|
ui.info("No commits found in \"#{app}\" for the given author and duration.")
|
data/lib/neetob/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: neetob
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Udai Gupta
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-03-
|
11
|
+
date: 2023-03-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|