neetob 0.2.2 → 0.2.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +16 -0
- data/Gemfile.lock +1 -1
- data/README.md +11 -10
- data/lib/neetob/cli/base.rb +12 -10
- data/lib/neetob/cli/fetchorupdate_repos/execute.rb +3 -4
- data/lib/neetob/cli/github/base.rb +0 -7
- data/lib/neetob/cli/github/commands.rb +8 -8
- 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 -13
- data/lib/neetob/cli/github/labels/delete.rb +19 -14
- data/lib/neetob/cli/github/labels/delete_all.rb +10 -12
- data/lib/neetob/cli/github/labels/list.rb +7 -9
- data/lib/neetob/cli/github/labels/show.rb +7 -9
- data/lib/neetob/cli/github/labels/update.rb +11 -13
- data/lib/neetob/cli/github/labels/upsert.rb +10 -12
- 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 +7 -9
- 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/commands.rb +2 -5
- data/lib/neetob/cli/users/commits.rb +3 -4
- data/lib/neetob/cli.rb +1 -3
- 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: 7fa4fc2f085419e84e0bbacf6cec1e365a60e276c26583dfc7fbebe969d49d8c
|
4
|
+
data.tar.gz: c45d3baa3ff401dec0fad7335f136242023ff031f377591e03ce9773545b7fb5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 01c2ddc361ec88eb2aaa4c84ed4485db66950a87dc572e7a1d705b35a95b92ea6311f736100add1c7938b050d68e37c0db5286c819ff9ef6537e7f81f27bc16d
|
7
|
+
data.tar.gz: 503235621a7d75727728500fcd51c238332ff39c05323b3a3d8e160b4c13fd792d77516f1ff9de215154a3ea1446b92af5ed9acf6a1ecc4784f1b8267524416c
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,21 @@
|
|
1
1
|
## [Unreleased]
|
2
2
|
|
3
|
+
### [0.2.4](https://www.github.com/bigbinary/neetob/compare/v0.2.3...v0.2.4) (2023-03-14)
|
4
|
+
|
5
|
+
|
6
|
+
### Bug Fixes
|
7
|
+
|
8
|
+
* Fixed commands to execute only for instances mentioned in the single source of truth file ([#206](https://www.github.com/bigbinary/neetob/issues/206)) ([e79a341](https://www.github.com/bigbinary/neetob/commit/e79a3414ad4ed4790333cff42b5376cf1660c47d))
|
9
|
+
* Fixed label delete command to skip deletion of labels that aren't found in the repo ([#195](https://www.github.com/bigbinary/neetob/issues/195)) ([d48626b](https://www.github.com/bigbinary/neetob/commit/d48626b1997a60c58e0fb023c3fb2e491e67a4da))
|
10
|
+
* Replaced `--all-neeto-repos` flag with the format `--apps "all"` ([#212](https://www.github.com/bigbinary/neetob/issues/212)) ([8c656cd](https://www.github.com/bigbinary/neetob/commit/8c656cd11ba1721a8b68e6e40d3ec439e93977ef))
|
11
|
+
|
12
|
+
### [0.2.3](https://www.github.com/bigbinary/neetob/compare/v0.2.2...v0.2.3) (2023-03-10)
|
13
|
+
|
14
|
+
|
15
|
+
### Bug Fixes
|
16
|
+
|
17
|
+
* 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))
|
18
|
+
|
3
19
|
### [0.2.2](https://www.github.com/bigbinary/neetob/compare/v0.2.1...v0.2.2) (2023-03-06)
|
4
20
|
|
5
21
|
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -59,6 +59,7 @@ Options:
|
|
59
59
|
|
60
60
|
| Option | Meaning |
|
61
61
|
| ------------ | --------------------------------- |
|
62
|
+
| --repos | Target repo names |
|
62
63
|
| --apps | Target app names |
|
63
64
|
| --sandbox | Sandbox mode |
|
64
65
|
| --no-sandbox | Non-Sandbox mode |
|
@@ -157,11 +158,11 @@ neetob github help
|
|
157
158
|
|
158
159
|
```sh
|
159
160
|
# Lists and counts all the open issues that are currently unassigned
|
160
|
-
neetob github issues list --count --state open --assignee none --
|
161
|
+
neetob github issues list --count --state open --assignee none --repos "neeto-*-staging"
|
161
162
|
|
162
163
|
# Lists, counts and filters all unassigned open issues that are labeled as "bug"
|
163
164
|
neetob github issues list --count --label bug --state open --assignee none \
|
164
|
-
--
|
165
|
+
--repos "neeto-*-staging"
|
165
166
|
```
|
166
167
|
|
167
168
|
### Labels
|
@@ -170,10 +171,10 @@ The `labels` command provides an interface for interacting with Github labels.
|
|
170
171
|
|
171
172
|
```sh
|
172
173
|
# Lists the details of all the labels in the Github repo
|
173
|
-
neetob github labels list --
|
174
|
+
neetob github labels list --repos "neeto-*-staging"
|
174
175
|
|
175
176
|
# Provides the details for a specific label in the Github repo
|
176
|
-
neetob github labels show --name priority --
|
177
|
+
neetob github labels show --name priority --repos "neeto-*-staging"
|
177
178
|
|
178
179
|
# Changes the name of the label
|
179
180
|
neetob github labels update --old-name "High Priority" --new-name \
|
@@ -183,7 +184,7 @@ neetob github labels update --old-name "High Priority" --new-name \
|
|
183
184
|
neetob github labels upsert --all-neeto-repos
|
184
185
|
|
185
186
|
# Accepts a different JSON file using `path` option
|
186
|
-
neetob github labels upsert --path ~/Desktop/labels.json --
|
187
|
+
neetob github labels upsert --path ~/Desktop/labels.json --repos "neeto-*-staging"
|
187
188
|
|
188
189
|
# Upsert a single label using `name`, `color`, and `description` options
|
189
190
|
# No `#` is required while adding `color`
|
@@ -192,10 +193,10 @@ neetob github labels upsert --name UI --color 8250df --description \
|
|
192
193
|
|
193
194
|
# Deletes the given labels from the Github repos
|
194
195
|
neetob github labels delete --labels "High Priority" "Priority 1" "bug" \
|
195
|
-
--
|
196
|
+
--repos "neeto-*-staging"
|
196
197
|
|
197
198
|
# Deletes all the labels from the Github repos
|
198
|
-
neetob github labels delete_all --
|
199
|
+
neetob github labels delete_all --repos "neeto-*-staging"
|
199
200
|
```
|
200
201
|
|
201
202
|
Check out the default labels [file](data/github-labels.json) for the required JSON file structure.
|
@@ -216,7 +217,7 @@ Don't use `#` before the color code.
|
|
216
217
|
Searches for keywords across multiple neeto projects within specified files by utilizing the `search` command.
|
217
218
|
|
218
219
|
```sh
|
219
|
-
neetob github search --keyword neeto --path README.md --
|
220
|
+
neetob github search --keyword neeto --path README.md --repos "neeto-*-staging"
|
220
221
|
```
|
221
222
|
|
222
223
|
### Protect branch
|
@@ -224,7 +225,7 @@ neetob github search --keyword neeto --path README.md --apps "neeto-*-staging"
|
|
224
225
|
Updates branch protection rules in neeto repos by using the `protect_branch` command.
|
225
226
|
|
226
227
|
```sh
|
227
|
-
neetob github protect_branch --branch main --
|
228
|
+
neetob github protect_branch --branch main --repos "neeto-*-staging"
|
228
229
|
```
|
229
230
|
|
230
231
|
By default, file "data/branch-protection-rules.json" will be used for updating the branch protection rules.
|
@@ -244,7 +245,7 @@ To update the above-mentioned branch protection rules for the `main` branch of a
|
|
244
245
|
|
245
246
|
```sh
|
246
247
|
neetob github protect_branch --branch main --path ~/Desktop/branch-protection-rules.json \
|
247
|
-
--
|
248
|
+
--repos "neeto-*-staging"
|
248
249
|
```
|
249
250
|
|
250
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,12 +19,13 @@ 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)
|
23
|
+
all_neeto_repos = apps == ["all"]
|
23
24
|
inform_about_current_working_mode(sandbox_mode, quiet)
|
24
25
|
all_available_apps = sandbox_mode ?
|
25
26
|
testing_apps(platform_name) :
|
26
27
|
build_app_list_from_neeto_compliance(platform_name, all_neeto_repos)
|
27
|
-
matching_apps = match_apps(apps || ["*"], all_available_apps)
|
28
|
+
matching_apps = all_neeto_repos ? all_available_apps : match_apps(apps || ["*"], all_available_apps)
|
28
29
|
if matching_apps.length == 0
|
29
30
|
error_msg = sandbox_mode ?
|
30
31
|
"Only \"neeto-dummy\" app is available for sandbox mode. Remove the \"--sandbox\" flag to run the given command for all the neeto applications." :
|
@@ -49,19 +50,20 @@ module Neetob
|
|
49
50
|
end
|
50
51
|
|
51
52
|
def build_app_list_from_neeto_compliance(platform_name, all_neeto_repos)
|
52
|
-
|
53
|
-
|
53
|
+
neeto_products = NeetoCompliance::NeetoRepos.products
|
54
|
+
apps = all_neeto_repos ? fetch_all_neeto_repos : neeto_products.keys
|
55
|
+
platform_name == :heroku ? add_env_suffix(apps, neeto_products) : prefix_org_name(apps)
|
54
56
|
end
|
55
57
|
|
56
|
-
def add_env_suffix(apps)
|
58
|
+
def add_env_suffix(apps, neeto_products)
|
57
59
|
[
|
58
|
-
suffix_slug(apps, :staging),
|
59
|
-
suffix_slug(apps, :production)
|
60
|
-
].flatten.sort
|
60
|
+
suffix_slug(apps, :staging, neeto_products),
|
61
|
+
suffix_slug(apps, :production, neeto_products)
|
62
|
+
].flatten.compact.sort
|
61
63
|
end
|
62
64
|
|
63
|
-
def suffix_slug(apps, suffix)
|
64
|
-
apps.map { |app| "#{app}-#{suffix}" }
|
65
|
+
def suffix_slug(apps, suffix, neeto_products)
|
66
|
+
apps.map { |app| neeto_products.dig(app, suffix.to_s) ? "#{app}-#{suffix}" : nil }
|
65
67
|
end
|
66
68
|
|
67
69
|
def prefix_org_name(apps)
|
@@ -6,17 +6,16 @@ module Neetob
|
|
6
6
|
class CLI
|
7
7
|
module FetchorupdateRepos
|
8
8
|
class Execute < Base
|
9
|
-
attr_accessor :sandbox, :apps
|
9
|
+
attr_accessor :sandbox, :apps
|
10
10
|
|
11
|
-
def initialize(sandbox = false,
|
11
|
+
def initialize(sandbox = false, apps = ["*"])
|
12
12
|
super()
|
13
13
|
@sandbox = sandbox
|
14
14
|
@apps = apps
|
15
|
-
@all_neeto_repos = all_neeto_repos
|
16
15
|
end
|
17
16
|
|
18
17
|
def run
|
19
|
-
neeto_apps =
|
18
|
+
neeto_apps = find_all_matching_apps_or_repos(apps, :github, sandbox)
|
20
19
|
neeto_apps.each do |app|
|
21
20
|
app_name = app.split("/").last
|
22
21
|
ui.info("\nWorking on #{app_name}\n")
|
@@ -23,13 +23,6 @@ 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(apps, all_neeto_repos)
|
27
|
-
if (apps.nil? && !all_neeto_repos) || (!apps.nil? && all_neeto_repos)
|
28
|
-
ui.error("Please provide either \"apps\" or \"all-neeto-repos\" option.")
|
29
|
-
exit
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
26
|
private
|
34
27
|
|
35
28
|
def read_and_parse_auth_params_from_env
|
@@ -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,13 +44,13 @@ 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 :
|
48
|
-
|
49
|
-
|
47
|
+
option :repos, type: :array, aliases: "-r",
|
48
|
+
desc:
|
49
|
+
"Github repo names. Can be matched using the '*' wildcard. Example: \"neeto*\" \"neeto-cal-web\", also providing \"all\" as value matches all neeto repos.",
|
50
|
+
required: true
|
50
51
|
def protect_branch
|
51
52
|
ProtectBranch.new(
|
52
|
-
options[:branch], options[:
|
53
|
-
options[:all_neeto_repos]).run
|
53
|
+
options[:branch], options[:repos], options[:path], options[:sandbox]).run
|
54
54
|
end
|
55
55
|
end
|
56
56
|
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\", also providing \"all\" as value matches all neeto repos."
|
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,19 @@ 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
|
21
|
-
class_option :all_neeto_repos,
|
22
|
-
type: :boolean, aliases: "--all", default: false,
|
23
|
-
desc: "Use this flag for working with all neeto repos"
|
18
|
+
class_option :repos,
|
19
|
+
type: :array, aliases: "-r", required: true,
|
20
|
+
desc: "Github repo names. Can be matched using the '*' wildcard. Example: \"neeto*\" \"neeto-cal-web\", also providing \"all\" as value matches all neeto repos."
|
24
21
|
|
25
22
|
desc "list", "List all the labels in the Github repos"
|
26
23
|
def list
|
27
|
-
List.new(options[:
|
24
|
+
List.new(options[:repos], options[:sandbox]).run
|
28
25
|
end
|
29
26
|
|
30
27
|
desc "show", "Show details about the given label in the Github repos"
|
31
28
|
option :name, type: :string, aliases: "-n", required: true, desc: "Name of the label"
|
32
29
|
def show
|
33
|
-
Show.new(options[:
|
30
|
+
Show.new(options[:repos], options[:name], options[:sandbox]).run
|
34
31
|
end
|
35
32
|
|
36
33
|
desc "upsert", "Create and update labels in the Github repos"
|
@@ -40,19 +37,19 @@ module Neetob
|
|
40
37
|
option :description, type: :string, desc: "Description of the label you want to upsert"
|
41
38
|
def upsert
|
42
39
|
Upsert.new(
|
43
|
-
options[:
|
40
|
+
options[:repos], options[:path], options[:sandbox], options[:name],
|
44
41
|
options[:color], options[:description]).run
|
45
42
|
end
|
46
43
|
|
47
44
|
desc "delete_all", "Delete all the labels from the Github repos"
|
48
45
|
def delete_all
|
49
|
-
DeleteAll.new(options[:
|
46
|
+
DeleteAll.new(options[:repos], options[:sandbox]).run
|
50
47
|
end
|
51
48
|
|
52
49
|
desc "delete", "Delete some labels from the Github repos"
|
53
50
|
option :labels, type: :array, required: true, desc: "Labels you want to delete from the repos."
|
54
51
|
def delete
|
55
|
-
Delete.new(options[:
|
52
|
+
Delete.new(options[:repos], options[:labels], options[:sandbox]).run
|
56
53
|
end
|
57
54
|
|
58
55
|
desc "update", "Update a label name in Github repos"
|
@@ -60,8 +57,7 @@ module Neetob
|
|
60
57
|
option :new_name, type: :string, required: true, desc: "New name for the updated label"
|
61
58
|
def update
|
62
59
|
Update.new(
|
63
|
-
options[:
|
64
|
-
options[:all_neeto_repos]).run
|
60
|
+
options[:repos], options[:old_name], options[:new_name], options[:sandbox]).run
|
65
61
|
end
|
66
62
|
end
|
67
63
|
end
|
@@ -9,34 +9,39 @@ module Neetob
|
|
9
9
|
module Github
|
10
10
|
module Labels
|
11
11
|
class Delete < Base
|
12
|
-
attr_accessor :
|
12
|
+
attr_accessor :repos, :sandbox, :labels
|
13
13
|
|
14
|
-
def initialize(
|
14
|
+
def initialize(repos, labels, sandbox = false)
|
15
15
|
super()
|
16
16
|
@labels = labels
|
17
|
-
@
|
17
|
+
@repos = repos
|
18
18
|
@sandbox = sandbox
|
19
|
-
@all_neeto_repos = all_neeto_repos
|
20
19
|
end
|
21
20
|
|
22
21
|
def run
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
ui.info("\n Deleting labels from #{app} repo \n")
|
22
|
+
matching_repos = find_all_matching_apps_or_repos(repos, :github, sandbox)
|
23
|
+
matching_repos.each do |repo|
|
24
|
+
ui.info("\nDeleting labels from #{repo} repo \n")
|
27
25
|
labels.each do |label|
|
28
|
-
|
26
|
+
begin
|
27
|
+
check_if_label_exist!(repo, label)
|
28
|
+
delete_label(repo, label)
|
29
|
+
rescue Octokit::NotFound
|
30
|
+
ui.say(" ↳The repo doesn't have the label \"#{label}\"")
|
31
|
+
end
|
29
32
|
end
|
30
33
|
end
|
31
34
|
end
|
32
35
|
|
33
36
|
private
|
34
37
|
|
35
|
-
def
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
38
|
+
def check_if_label_exist!(repo, label)
|
39
|
+
client.label(repo, label)
|
40
|
+
end
|
41
|
+
|
42
|
+
def delete_label(repo, label)
|
43
|
+
if client.delete_label!(repo, label)
|
44
|
+
ui.success(" ↳The \"#{label}\" label deleted successfully")
|
40
45
|
end
|
41
46
|
end
|
42
47
|
end
|
@@ -9,24 +9,22 @@ module Neetob
|
|
9
9
|
module Github
|
10
10
|
module Labels
|
11
11
|
class DeleteAll < Base
|
12
|
-
attr_accessor :
|
12
|
+
attr_accessor :repos, :sandbox
|
13
13
|
|
14
|
-
def initialize(
|
14
|
+
def initialize(repos, sandbox = false)
|
15
15
|
super()
|
16
|
-
@
|
16
|
+
@repos = repos
|
17
17
|
@sandbox = sandbox
|
18
|
-
@all_neeto_repos = all_neeto_repos
|
19
18
|
end
|
20
19
|
|
21
20
|
def run
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
ui.info("\n Working on #{app} repo \n")
|
21
|
+
matching_repos = find_all_matching_apps_or_repos(repos, :github, sandbox)
|
22
|
+
matching_repos.each do |repo|
|
23
|
+
ui.info("\n Working on #{repo} repo \n")
|
26
24
|
begin
|
27
|
-
labels = client.labels(
|
25
|
+
labels = client.labels(repo)
|
28
26
|
labels.each do |label|
|
29
|
-
delete_label(
|
27
|
+
delete_label(repo, label)
|
30
28
|
end
|
31
29
|
rescue StandardError => e
|
32
30
|
ExceptionHandler.new(e).process
|
@@ -36,8 +34,8 @@ module Neetob
|
|
36
34
|
|
37
35
|
private
|
38
36
|
|
39
|
-
def delete_label(
|
40
|
-
if client.delete_label!(
|
37
|
+
def delete_label(repo, label_details)
|
38
|
+
if client.delete_label!(repo, label_details[:name])
|
41
39
|
ui.success("The \"#{label_details[:name]}\" label deleted successfully")
|
42
40
|
else
|
43
41
|
ui.error("The \"#{label_details[:name]}\" label can't be deleted. Please try again")
|
@@ -9,22 +9,20 @@ module Neetob
|
|
9
9
|
module Github
|
10
10
|
module Labels
|
11
11
|
class List < Base
|
12
|
-
attr_accessor :
|
12
|
+
attr_accessor :repos, :sandbox
|
13
13
|
|
14
|
-
def initialize(
|
14
|
+
def initialize(repos, sandbox = false)
|
15
15
|
super()
|
16
|
-
@
|
16
|
+
@repos = repos
|
17
17
|
@sandbox = sandbox
|
18
|
-
@all_neeto_repos = all_neeto_repos
|
19
18
|
end
|
20
19
|
|
21
20
|
def run
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
ui.info("\n Labels of #{app} \n")
|
21
|
+
matching_repos = find_all_matching_apps_or_repos(repos, :github, sandbox)
|
22
|
+
matching_repos.each do |repo|
|
23
|
+
ui.info("\n Labels of #{repo} \n")
|
26
24
|
begin
|
27
|
-
labels = client.labels(
|
25
|
+
labels = client.labels(repo)
|
28
26
|
ui.success(labels)
|
29
27
|
rescue StandardError => e
|
30
28
|
ExceptionHandler.new(e).process
|
@@ -9,23 +9,21 @@ 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
|
13
13
|
|
14
|
-
def initialize(
|
14
|
+
def initialize(repos, label_name, sandbox = false)
|
15
15
|
super()
|
16
|
-
@
|
16
|
+
@repos = repos
|
17
17
|
@label_name = label_name
|
18
18
|
@sandbox = sandbox
|
19
|
-
@all_neeto_repos = all_neeto_repos
|
20
19
|
end
|
21
20
|
|
22
21
|
def run
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
ui.info("\n \"#{label_name}\" label details from #{app} \n")
|
22
|
+
matching_repos = find_all_matching_apps_or_repos(repos, :github, sandbox)
|
23
|
+
matching_repos.each do |repo|
|
24
|
+
ui.info("\n \"#{label_name}\" label details from #{repo} \n")
|
27
25
|
begin
|
28
|
-
label_details = client.label(
|
26
|
+
label_details = client.label(repo, label_name)
|
29
27
|
ui.success(label_details.inspect)
|
30
28
|
rescue StandardError => e
|
31
29
|
ExceptionHandler.new(e).process
|
@@ -9,26 +9,24 @@ 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
|
13
13
|
|
14
|
-
def initialize(
|
14
|
+
def initialize(repos, old_name, new_name, sandbox = false)
|
15
15
|
super()
|
16
|
-
@
|
16
|
+
@repos = repos
|
17
17
|
@sandbox = sandbox
|
18
18
|
@old_name = old_name
|
19
19
|
@new_name = new_name
|
20
|
-
@all_neeto_repos = all_neeto_repos
|
21
20
|
end
|
22
21
|
|
23
22
|
def run
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
ui.info("\nUpdating label for #{app} repo \n")
|
23
|
+
matching_repos = find_all_matching_apps_or_repos(repos, :github, sandbox)
|
24
|
+
matching_repos.each do |repo|
|
25
|
+
ui.info("\nUpdating label for #{repo} repo \n")
|
28
26
|
begin
|
29
|
-
update_label!(
|
27
|
+
update_label!(repo, old_name, new_name)
|
30
28
|
rescue Octokit::NotFound
|
31
|
-
ui.say("Ignoring update for #{
|
29
|
+
ui.say("Ignoring update for #{repo} repo as it doesn't have the \"#{old_name}\" label.")
|
32
30
|
rescue StandardError => e
|
33
31
|
ExceptionHandler.new(e).process
|
34
32
|
end
|
@@ -37,12 +35,12 @@ module Neetob
|
|
37
35
|
|
38
36
|
private
|
39
37
|
|
40
|
-
def update_label!(
|
41
|
-
client.label(
|
38
|
+
def update_label!(repo, old_name, new_name)
|
39
|
+
client.label(repo, new_name)
|
42
40
|
ui.error("Label with name \"#{new_name}\" already exists.")
|
43
41
|
nil
|
44
42
|
rescue Octokit::NotFound
|
45
|
-
client.update_label(
|
43
|
+
client.update_label(repo, old_name, { name: new_name })
|
46
44
|
ui.success("Label \"#{old_name}\" updated to \"#{new_name}\" successfully")
|
47
45
|
rescue StandardError => e
|
48
46
|
ExceptionHandler.new(e).process
|
@@ -11,30 +11,28 @@ 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, :name, :color, :description
|
15
15
|
|
16
|
-
def initialize(
|
16
|
+
def initialize(repos, required_labels_json_file_path = "", sandbox = 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
|
-
@all_neeto_repos = all_neeto_repos
|
23
22
|
@name = name
|
24
23
|
@color = color
|
25
24
|
@description = description
|
26
25
|
end
|
27
26
|
|
28
27
|
def run
|
29
|
-
|
30
|
-
matching_apps = find_all_matching_apps(apps, :github, sandbox, false, all_neeto_repos)
|
28
|
+
matching_repos = find_all_matching_apps_or_repos(repos, :github, sandbox)
|
31
29
|
inform_about_default_labels_file
|
32
|
-
|
33
|
-
ui.info("\nWorking on #{
|
30
|
+
matching_repos.each do |repo|
|
31
|
+
ui.info("\nWorking on #{repo} repo\n")
|
34
32
|
begin
|
35
33
|
required_labels = get_required_labels
|
36
34
|
required_labels.each do |label|
|
37
|
-
create_or_update_label(
|
35
|
+
create_or_update_label(repo, label)
|
38
36
|
sleep(1)
|
39
37
|
end
|
40
38
|
rescue StandardError => e
|
@@ -68,13 +66,13 @@ module Neetob
|
|
68
66
|
]
|
69
67
|
end
|
70
68
|
|
71
|
-
def create_or_update_label(
|
69
|
+
def create_or_update_label(repo, label_details)
|
72
70
|
begin
|
73
|
-
client.update_label(
|
71
|
+
client.update_label(repo, label_details["name"], label_details)
|
74
72
|
ui.success("Label \"#{label_details["name"]}\" updated successfully")
|
75
73
|
rescue Octokit::NotFound
|
76
74
|
client.add_label(
|
77
|
-
|
75
|
+
repo, label_details["name"], label_details["color"] || WHITE_COLOR_HEX_CODE,
|
78
76
|
label_details)
|
79
77
|
ui.success("Label \"#{label_details["name"]}\" created successfully")
|
80
78
|
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,25 @@ 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
|
10
10
|
|
11
|
-
def initialize(branch_name,
|
11
|
+
def initialize(branch_name, repos, required_rules_json_file_path = "", sandbox = 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
|
-
@all_neeto_repos = all_neeto_repos
|
18
17
|
end
|
19
18
|
|
20
19
|
def run
|
21
|
-
|
22
|
-
matching_apps = find_all_matching_apps(apps, :github, sandbox, false, all_neeto_repos)
|
20
|
+
matching_repos = find_all_matching_apps_or_repos(repos, :github, sandbox)
|
23
21
|
inform_about_default_rules_file
|
24
|
-
|
25
|
-
ui.info("\n Working on \"#{
|
22
|
+
matching_repos.each do |repo|
|
23
|
+
ui.info("\n Working on \"#{repo}\" repo")
|
26
24
|
ui.info(" Updating \"#{branch_name}\" branch protection rules")
|
27
25
|
rules = read_json_file(required_rules_json_file_path || default_rules_file_path)
|
28
26
|
rules_with_symbol_keys = rules.transform_keys(&:to_sym)
|
29
|
-
client.protect_branch(
|
27
|
+
client.protect_branch(repo, branch_name, rules_with_symbol_keys)
|
30
28
|
ui.success("Branch protection rules updated successfully")
|
31
29
|
end
|
32
30
|
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
|
@@ -14,15 +14,12 @@ module Neetob
|
|
14
14
|
end
|
15
15
|
|
16
16
|
desc "commits", "List the commits of a user across the neeto apps"
|
17
|
-
option :apps, type: :array, aliases: "-a", default: ["*"], desc: "Github app names. Can be matched using the '*' wildcard. Example: \"neeto*\" \"neeto-cal-web\""
|
17
|
+
option :apps, type: :array, aliases: "-a", default: ["*"], desc: "Github app names. Can be matched using the '*' wildcard. Example: \"neeto*\" \"neeto-cal-web\", also providing \"all\" as value matches all neeto repos."
|
18
18
|
option :author, type: :string, required: true, desc: "Github username of the person whose commits you want to list"
|
19
19
|
option :duration, type: :string, required: true, desc: "Duration for which you want to list the commits. Example: \"6.months\" \"10.days\""
|
20
|
-
option :all_neeto_repos, type: :boolean, aliases: "--all",
|
21
|
-
desc: "Use this flag for working with all neeto repos", default: false
|
22
20
|
def commits
|
23
21
|
Commits.new(
|
24
|
-
options[:author], options[:duration], options[:apps],
|
25
|
-
options[:sandbox], options[:all_neeto_repos]).run
|
22
|
+
options[:author], options[:duration], options[:apps], options[:sandbox]).run
|
26
23
|
end
|
27
24
|
end
|
28
25
|
end
|
@@ -11,15 +11,14 @@ module Neetob
|
|
11
11
|
class Commits < Github::Base
|
12
12
|
include ActionView::Helpers::DateHelper
|
13
13
|
|
14
|
-
attr_accessor :sandbox, :apps, :author, :duration
|
14
|
+
attr_accessor :sandbox, :apps, :author, :duration
|
15
15
|
|
16
|
-
def initialize(author, duration, apps = ["*"], sandbox = false
|
16
|
+
def initialize(author, duration, apps = ["*"], sandbox = false)
|
17
17
|
super()
|
18
18
|
@sandbox = sandbox
|
19
19
|
@apps = apps
|
20
20
|
@author = author
|
21
21
|
@duration = duration
|
22
|
-
@all_neeto_repos = all_neeto_repos
|
23
22
|
end
|
24
23
|
|
25
24
|
def run
|
@@ -32,7 +31,7 @@ module Neetob
|
|
32
31
|
private
|
33
32
|
|
34
33
|
def build_commit_rows
|
35
|
-
commits =
|
34
|
+
commits = find_all_matching_apps_or_repos(apps, :github, sandbox, true).map do |app|
|
36
35
|
commits = commits_within_range(app)
|
37
36
|
if commits&.empty?
|
38
37
|
ui.info("No commits found in \"#{app}\" for the given author and duration.")
|
data/lib/neetob/cli.rb
CHANGED
@@ -33,10 +33,8 @@ module Neetob
|
|
33
33
|
subcommand "local", Local::Commands
|
34
34
|
|
35
35
|
desc "make_repos_uptodate", "Uptodate all neeto repos"
|
36
|
-
option :all_neeto_repos, type: :boolean, aliases: "--all", desc: "Use this flag for working with all neeto repos",
|
37
|
-
default: false
|
38
36
|
def make_repos_uptodate
|
39
|
-
FetchorupdateRepos::Execute.new(options[:sandbox]
|
37
|
+
FetchorupdateRepos::Execute.new(options[:sandbox]).run
|
40
38
|
end
|
41
39
|
end
|
42
40
|
end
|
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.4
|
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-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|