neetob 0.1.1 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.semaphore/semaphore.yml +3 -4
- data/CHANGELOG.md +14 -0
- data/Gemfile +10 -0
- data/Gemfile.lock +17 -4
- data/README.md +64 -36
- data/bookmarks.md +5 -0
- data/data/branch-protection-rules.json +1 -1
- data/data/github-labels.json +7 -2
- data/lib/neetob/cli/base.rb +22 -10
- data/lib/neetob/cli/fetchorupdate_repos/execute.rb +5 -3
- data/lib/neetob/cli/github/base.rb +7 -0
- data/lib/neetob/cli/github/commands.rb +6 -2
- data/lib/neetob/cli/github/labels/commands.rb +18 -10
- data/lib/neetob/cli/github/labels/delete.rb +5 -3
- data/lib/neetob/cli/github/labels/delete_all.rb +5 -3
- data/lib/neetob/cli/github/labels/list.rb +5 -3
- data/lib/neetob/cli/github/labels/show.rb +5 -3
- data/lib/neetob/cli/github/labels/update.rb +5 -3
- data/lib/neetob/cli/github/labels/upsert.rb +41 -7
- data/lib/neetob/cli/github/make_pr/base.rb +2 -1
- data/lib/neetob/cli/github/make_pr/commands.rb +4 -1
- data/lib/neetob/cli/github/make_pr/compliance_fix.rb +6 -1
- data/lib/neetob/cli/github/make_pr/script.rb +4 -3
- data/lib/neetob/cli/github/protect_branch.rb +5 -3
- data/lib/neetob/cli/heroku/config_vars/upsert.rb +6 -2
- data/lib/neetob/cli/heroku/execute.rb +2 -2
- data/lib/neetob/cli/users/commands.rb +3 -1
- data/lib/neetob/cli/users/commits.rb +71 -22
- data/lib/neetob/cli.rb +3 -1
- data/lib/neetob/version.rb +1 -1
- data/neetob.gemspec +50 -0
- metadata +7 -56
- data/LICENSE.txt +0 -21
- data/Users/chiragshah/Workspace/bigbinary/neeto/neetob/neeto_compliance/lib/neeto_compliance/github_access.rb +0 -29
- data/Users/chiragshah/Workspace/bigbinary/neeto/neetob/neeto_compliance/lib/neeto_compliance/neeto_apps.rb +0 -35
- data/Users/chiragshah/Workspace/bigbinary/neeto/neetob/neeto_compliance/lib/neeto_compliance/neeto_commons.rb +0 -16
- data/Users/chiragshah/Workspace/bigbinary/neeto/neetob/neeto_compliance/lib/neeto_compliance/runner.rb +0 -35
- data/Users/chiragshah/Workspace/bigbinary/neeto/neetob/neeto_compliance/lib/neeto_compliance/skippable.rb +0 -19
- data/Users/chiragshah/Workspace/bigbinary/neeto/neetob/neeto_compliance/lib/neeto_compliance/sync_neeto_commons/sync_bin.rb +0 -32
- data/Users/chiragshah/Workspace/bigbinary/neeto/neetob/neeto_compliance/lib/neeto_compliance/sync_neeto_commons/sync_formatters.rb +0 -35
- data/Users/chiragshah/Workspace/bigbinary/neeto/neetob/neeto_compliance/lib/neeto_compliance/sync_neeto_commons/sync_husky.rb +0 -33
- data/Users/chiragshah/Workspace/bigbinary/neeto/neetob/neeto_compliance/lib/neeto_compliance/sync_neeto_commons/sync_misc.rb +0 -36
- data/Users/chiragshah/Workspace/bigbinary/neeto/neetob/neeto_compliance/lib/neeto_compliance/sync_neeto_commons/sync_test_support.rb +0 -38
- data/Users/chiragshah/Workspace/bigbinary/neeto/neetob/neeto_compliance/lib/neeto_compliance/sync_neeto_commons.rb +0 -36
- data/Users/chiragshah/Workspace/bigbinary/neeto/neetob/neeto_compliance/lib/neeto_compliance/verifiers/auto_update_prs_with_latest_master_verifier.rb +0 -25
- data/Users/chiragshah/Workspace/bigbinary/neeto/neetob/neeto_compliance/lib/neeto_compliance/verifiers/base.rb +0 -72
- data/Users/chiragshah/Workspace/bigbinary/neeto/neetob/neeto_compliance/lib/neeto_compliance/verifiers/bundler_version_verifier.rb +0 -53
- data/Users/chiragshah/Workspace/bigbinary/neeto/neetob/neeto_compliance/lib/neeto_compliance/verifiers/circleci_config_verifier.rb +0 -25
- data/Users/chiragshah/Workspace/bigbinary/neeto/neetob/neeto_compliance/lib/neeto_compliance/verifiers/common_gemfile_verifier.rb +0 -25
- data/Users/chiragshah/Workspace/bigbinary/neeto/neetob/neeto_compliance/lib/neeto_compliance/verifiers/common_initializers_verifier.rb +0 -25
- data/Users/chiragshah/Workspace/bigbinary/neeto/neetob/neeto_compliance/lib/neeto_compliance/verifiers/cypress_config_verifier.rb +0 -46
- data/Users/chiragshah/Workspace/bigbinary/neeto/neetob/neeto_compliance/lib/neeto_compliance/verifiers/cypress_plugins_index_verifier.rb +0 -25
- data/Users/chiragshah/Workspace/bigbinary/neeto/neetob/neeto_compliance/lib/neeto_compliance/verifiers/docker_file_dev_verifier.rb +0 -25
- data/Users/chiragshah/Workspace/bigbinary/neeto/neetob/neeto_compliance/lib/neeto_compliance/verifiers/environment_config_verifier.rb +0 -38
- data/Users/chiragshah/Workspace/bigbinary/neeto/neetob/neeto_compliance/lib/neeto_compliance/verifiers/gem_version_verifier.rb +0 -38
- data/Users/chiragshah/Workspace/bigbinary/neeto/neetob/neeto_compliance/lib/neeto_compliance/verifiers/gems_verifier_base.rb +0 -34
- data/Users/chiragshah/Workspace/bigbinary/neeto/neetob/neeto_compliance/lib/neeto_compliance/verifiers/gitignore_file_verifier.rb +0 -39
- data/Users/chiragshah/Workspace/bigbinary/neeto/neetob/neeto_compliance/lib/neeto_compliance/verifiers/jsconfig_verifier.rb +0 -100
- data/Users/chiragshah/Workspace/bigbinary/neeto/neetob/neeto_compliance/lib/neeto_compliance/verifiers/neeto_auth_gems_verifier.rb +0 -20
- data/Users/chiragshah/Workspace/bigbinary/neeto/neetob/neeto_compliance/lib/neeto_compliance/verifiers/neeto_commons_sync_verifier.rb +0 -42
- data/Users/chiragshah/Workspace/bigbinary/neeto/neetob/neeto_compliance/lib/neeto_compliance/verifiers/neeto_gems_version_verifier.rb +0 -24
- data/Users/chiragshah/Workspace/bigbinary/neeto/neetob/neeto_compliance/lib/neeto_compliance/verifiers/newrelic_verifier.rb +0 -25
- data/Users/chiragshah/Workspace/bigbinary/neeto/neetob/neeto_compliance/lib/neeto_compliance/verifiers/node_version_verifier.rb +0 -63
- data/Users/chiragshah/Workspace/bigbinary/neeto/neetob/neeto_compliance/lib/neeto_compliance/verifiers/package_dependencies_version_verifier.rb +0 -62
- data/Users/chiragshah/Workspace/bigbinary/neeto/neetob/neeto_compliance/lib/neeto_compliance/verifiers/package_json_verifier.rb +0 -39
- data/Users/chiragshah/Workspace/bigbinary/neeto/neetob/neeto_compliance/lib/neeto_compliance/verifiers/roles_verifier.rb +0 -22
- data/Users/chiragshah/Workspace/bigbinary/neeto/neetob/neeto_compliance/lib/neeto_compliance/verifiers/ruby_version_verifier.rb +0 -25
- data/Users/chiragshah/Workspace/bigbinary/neeto/neetob/neeto_compliance/lib/neeto_compliance/verifiers/semaphoreci_config_verifier.rb +0 -162
- data/Users/chiragshah/Workspace/bigbinary/neeto/neetob/neeto_compliance/lib/neeto_compliance/verifiers/sidekiq_queues_verifier.rb +0 -34
- data/Users/chiragshah/Workspace/bigbinary/neeto/neetob/neeto_compliance/lib/neeto_compliance/verifiers/simplecov_config_verifier.rb +0 -28
- data/Users/chiragshah/Workspace/bigbinary/neeto/neetob/neeto_compliance/lib/neeto_compliance/verifiers/sitemap_config_verifier.rb +0 -29
- data/Users/chiragshah/Workspace/bigbinary/neeto/neetob/neeto_compliance/lib/neeto_compliance/verifiers/slugignore_file_verifier.rb +0 -25
- data/Users/chiragshah/Workspace/bigbinary/neeto/neetob/neeto_compliance/lib/neeto_compliance/verifiers/sync_neeto_commons_verifier/bin_files_verifier.rb +0 -29
- data/Users/chiragshah/Workspace/bigbinary/neeto/neetob/neeto_compliance/lib/neeto_compliance/verifiers/sync_neeto_commons_verifier/formatter_files_verifier.rb +0 -29
- data/Users/chiragshah/Workspace/bigbinary/neeto/neetob/neeto_compliance/lib/neeto_compliance/verifiers/sync_neeto_commons_verifier/husky_files_verifier.rb +0 -29
- data/Users/chiragshah/Workspace/bigbinary/neeto/neetob/neeto_compliance/lib/neeto_compliance/verifiers/sync_neeto_commons_verifier/misc_files_verifier.rb +0 -29
- data/Users/chiragshah/Workspace/bigbinary/neeto/neetob/neeto_compliance/lib/neeto_compliance/verifiers/sync_neeto_commons_verifier/test_support_files_verifier.rb +0 -28
- data/Users/chiragshah/Workspace/bigbinary/neeto/neetob/neeto_compliance/lib/neeto_compliance/verifiers/sync_neeto_commons_verifier.rb +0 -31
- data/Users/chiragshah/Workspace/bigbinary/neeto/neetob/neeto_compliance/lib/neeto_compliance/verifiers/webpack_configuration_verifier.rb +0 -44
- data/Users/chiragshah/Workspace/bigbinary/neeto/neetob/neeto_compliance/lib/neeto_compliance/verifiers/webpacker_config_verifier.rb +0 -29
- data/Users/chiragshah/Workspace/bigbinary/neeto/neetob/neeto_compliance/lib/neeto_compliance/verifiers_list.rb +0 -61
- data/Users/chiragshah/Workspace/bigbinary/neeto/neetob/neeto_compliance/lib/neeto_compliance/version.rb +0 -5
- data/env.sample +0 -1
@@ -9,17 +9,19 @@ module Neetob
|
|
9
9
|
module Github
|
10
10
|
module Labels
|
11
11
|
class Show < Base
|
12
|
-
attr_accessor :apps, :label_name, :sandbox
|
12
|
+
attr_accessor :apps, :label_name, :sandbox, :all_neeto_repos
|
13
13
|
|
14
|
-
def initialize(apps, label_name, sandbox = false)
|
14
|
+
def initialize(apps, label_name, sandbox = false, all_neeto_repos = false)
|
15
15
|
super()
|
16
16
|
@apps = apps
|
17
17
|
@label_name = label_name
|
18
18
|
@sandbox = sandbox
|
19
|
+
@all_neeto_repos = all_neeto_repos
|
19
20
|
end
|
20
21
|
|
21
22
|
def run
|
22
|
-
|
23
|
+
check_for_apps_and_all_neeto_repos_option(apps, all_neeto_repos)
|
24
|
+
matching_apps = find_all_matching_apps(apps, :github, sandbox, false, all_neeto_repos)
|
23
25
|
matching_apps.each do |app|
|
24
26
|
ui.info("\n \"#{label_name}\" label details from #{app} \n")
|
25
27
|
begin
|
@@ -9,18 +9,20 @@ module Neetob
|
|
9
9
|
module Github
|
10
10
|
module Labels
|
11
11
|
class Update < Base
|
12
|
-
attr_accessor :apps, :sandbox, :old_name, :new_name
|
12
|
+
attr_accessor :apps, :sandbox, :old_name, :new_name, :all_neeto_repos
|
13
13
|
|
14
|
-
def initialize(apps, old_name, new_name, sandbox = false)
|
14
|
+
def initialize(apps, old_name, new_name, sandbox = false, all_neeto_repos = false)
|
15
15
|
super()
|
16
16
|
@apps = apps
|
17
17
|
@sandbox = sandbox
|
18
18
|
@old_name = old_name
|
19
19
|
@new_name = new_name
|
20
|
+
@all_neeto_repos = all_neeto_repos
|
20
21
|
end
|
21
22
|
|
22
23
|
def run
|
23
|
-
|
24
|
+
check_for_apps_and_all_neeto_repos_option(apps, all_neeto_repos)
|
25
|
+
matching_apps = find_all_matching_apps(apps, :github, sandbox, false, all_neeto_repos)
|
24
26
|
matching_apps.each do |app|
|
25
27
|
ui.info("\n Updating label for #{app} repo \n")
|
26
28
|
update_label!(app, old_name, new_name)
|
@@ -9,24 +9,33 @@ module Neetob
|
|
9
9
|
module Github
|
10
10
|
module Labels
|
11
11
|
class Upsert < Base
|
12
|
-
|
12
|
+
WHITE_COLOR_HEX_CODE = "ffffff"
|
13
13
|
|
14
|
-
|
14
|
+
attr_accessor :apps, :required_labels_json_file_path, :sandbox, :all_neeto_repos, :name, :color, :description
|
15
|
+
|
16
|
+
def initialize(apps, required_labels_json_file_path = "", sandbox = false, all_neeto_repos = false,
|
17
|
+
name = "", color = "", description = "")
|
15
18
|
super()
|
16
19
|
@apps = apps
|
17
20
|
@required_labels_json_file_path = required_labels_json_file_path
|
18
21
|
@sandbox = sandbox
|
22
|
+
@all_neeto_repos = all_neeto_repos
|
23
|
+
@name = name
|
24
|
+
@color = color
|
25
|
+
@description = description
|
19
26
|
end
|
20
27
|
|
21
28
|
def run
|
22
|
-
|
29
|
+
check_for_apps_and_all_neeto_repos_option(apps, all_neeto_repos)
|
30
|
+
matching_apps = find_all_matching_apps(apps, :github, sandbox, false, all_neeto_repos)
|
23
31
|
inform_about_default_labels_file
|
24
32
|
matching_apps.each do |app|
|
25
|
-
ui.info("\
|
33
|
+
ui.info("\nWorking on #{app} repo\n")
|
26
34
|
begin
|
27
|
-
required_labels =
|
35
|
+
required_labels = get_required_labels
|
28
36
|
required_labels.each do |label|
|
29
37
|
create_or_update_label(app, label)
|
38
|
+
sleep(1)
|
30
39
|
end
|
31
40
|
rescue StandardError => e
|
32
41
|
ExceptionHandler.new(e).process
|
@@ -36,12 +45,37 @@ module Neetob
|
|
36
45
|
|
37
46
|
private
|
38
47
|
|
48
|
+
def get_required_labels
|
49
|
+
if name.blank? && (!color.blank? || !description.blank?)
|
50
|
+
ui.error("Please provide \"name\" for the label you want to upsert.")
|
51
|
+
exit
|
52
|
+
end
|
53
|
+
|
54
|
+
if !name.blank?
|
55
|
+
return create_label_payload
|
56
|
+
end
|
57
|
+
|
58
|
+
read_json_file(required_labels_json_file_path || default_labels_file_path)
|
59
|
+
end
|
60
|
+
|
61
|
+
def create_label_payload
|
62
|
+
[
|
63
|
+
{
|
64
|
+
"name" => name,
|
65
|
+
"color" => color,
|
66
|
+
"description" => description
|
67
|
+
}.compact
|
68
|
+
]
|
69
|
+
end
|
70
|
+
|
39
71
|
def create_or_update_label(app, label_details)
|
40
72
|
begin
|
41
73
|
client.update_label(app, label_details["name"], label_details)
|
42
74
|
ui.success("Label \"#{label_details["name"]}\" updated successfully")
|
43
75
|
rescue Octokit::NotFound
|
44
|
-
client.add_label(
|
76
|
+
client.add_label(
|
77
|
+
app, label_details["name"], label_details["color"] || WHITE_COLOR_HEX_CODE,
|
78
|
+
label_details)
|
45
79
|
ui.success("Label \"#{label_details["name"]}\" created successfully")
|
46
80
|
end
|
47
81
|
end
|
@@ -51,7 +85,7 @@ module Neetob
|
|
51
85
|
end
|
52
86
|
|
53
87
|
def inform_about_default_labels_file
|
54
|
-
if required_labels_json_file_path.nil?
|
88
|
+
if required_labels_json_file_path.nil? && name.nil?
|
55
89
|
ui.info("Upserting labels from the \"neetob/data/github-labels.json\" file")
|
56
90
|
end
|
57
91
|
end
|
@@ -33,7 +33,8 @@ module Neetob
|
|
33
33
|
end
|
34
34
|
|
35
35
|
def add_commmit_and_push_changes(app)
|
36
|
-
`#{cd_to_app_in_tmp_dir(app)} && git add . &&
|
36
|
+
`#{cd_to_app_in_tmp_dir(app)} && git add . && \\
|
37
|
+
git commit -m "#{pr_title}" && git push -u origin #{branch_name} --force`
|
37
38
|
end
|
38
39
|
|
39
40
|
def delete_local_feature_branch(app)
|
@@ -27,8 +27,11 @@ module Neetob
|
|
27
27
|
desc: "Path to UNIX executable script which will be run for each product", required: true
|
28
28
|
option :title, type: :string, aliases: "-t", desc: "Title for the PR"
|
29
29
|
option :branch, type: :string, aliases: "-b", desc: "Feature branch name for the PR"
|
30
|
+
option :description, type: :string, aliases: "-d", desc: "Description of the PR"
|
30
31
|
def script
|
31
|
-
Script.new(
|
32
|
+
Script.new(
|
33
|
+
options[:apps], options[:path], options[:title], options[:branch], options[:description],
|
34
|
+
options[:sandbox]).run
|
32
35
|
end
|
33
36
|
end
|
34
37
|
end
|
@@ -26,6 +26,7 @@ module Neetob
|
|
26
26
|
clone_app_in_tmp_dir(app)
|
27
27
|
check_and_delete_remote_branch(app)
|
28
28
|
bundle_install(app)
|
29
|
+
fix_neeto_audit(app)
|
29
30
|
ui.info(add_commmit_and_push_changes(app))
|
30
31
|
delete_local_feature_branch(app)
|
31
32
|
res = client.create_pull_request(app, "main", BRANCH_NAME, PR_TITLE)
|
@@ -40,7 +41,11 @@ module Neetob
|
|
40
41
|
private
|
41
42
|
|
42
43
|
def bundle_install(app)
|
43
|
-
`#{cd_to_app_in_tmp_dir(app)} && bundle`
|
44
|
+
`#{cd_to_app_in_tmp_dir(app)} && bundle install`
|
45
|
+
end
|
46
|
+
|
47
|
+
def fix_neeto_audit(app)
|
48
|
+
`#{cd_to_app_in_tmp_dir(app)} && bundle exec neeto-audit -a`
|
44
49
|
end
|
45
50
|
end
|
46
51
|
end
|
@@ -9,13 +9,14 @@ module Neetob
|
|
9
9
|
module Github
|
10
10
|
module MakePr
|
11
11
|
class Script < Base
|
12
|
-
attr_accessor :apps, :sandbox, :path_to_the_script_file
|
12
|
+
attr_accessor :apps, :sandbox, :path_to_the_script_file, :pr_description
|
13
13
|
|
14
|
-
def initialize(apps, path_to_the_script_file, pr_title, branch_name, sandbox = false)
|
14
|
+
def initialize(apps, path_to_the_script_file, pr_title, branch_name, pr_description, sandbox = false)
|
15
15
|
super(pr_title, branch_name)
|
16
16
|
@apps = apps
|
17
17
|
@sandbox = sandbox
|
18
18
|
@path_to_the_script_file = path_to_the_script_file
|
19
|
+
@pr_description = pr_description
|
19
20
|
end
|
20
21
|
|
21
22
|
def run
|
@@ -30,7 +31,7 @@ module Neetob
|
|
30
31
|
execute_script(app)
|
31
32
|
ui.info(add_commmit_and_push_changes(app))
|
32
33
|
delete_local_feature_branch(app)
|
33
|
-
res = client.create_pull_request(app, "main", branch_name, pr_title)
|
34
|
+
res = client.create_pull_request(app, "main", branch_name, pr_title, pr_description)
|
34
35
|
ui.success("PR created in \"#{app}\" project successfully.")
|
35
36
|
rescue StandardError => e
|
36
37
|
ExceptionHandler.new(e).process
|
@@ -6,18 +6,20 @@ 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, :apps, :sandbox
|
9
|
+
attr_accessor :branch_name, :required_rules_json_file_path, :apps, :sandbox, :all_neeto_repos
|
10
10
|
|
11
|
-
def initialize(branch_name, apps, required_rules_json_file_path = "", sandbox = false)
|
11
|
+
def initialize(branch_name, apps, 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
|
@apps = apps
|
16
16
|
@sandbox = sandbox
|
17
|
+
@all_neeto_repos = all_neeto_repos
|
17
18
|
end
|
18
19
|
|
19
20
|
def run
|
20
|
-
|
21
|
+
check_for_apps_and_all_neeto_repos_option(apps, all_neeto_repos)
|
22
|
+
matching_apps = find_all_matching_apps(apps, :github, sandbox, false, all_neeto_repos)
|
21
23
|
inform_about_default_rules_file
|
22
24
|
matching_apps.each do |app|
|
23
25
|
ui.info("\n Working on \"#{app}\" repo")
|
@@ -29,7 +29,9 @@ required_config_vars_with_project_keys_json_file_path, sandbox = false)
|
|
29
29
|
inform_about_default_config_vars_file
|
30
30
|
|
31
31
|
apps_to_be_updated.each do |app|
|
32
|
-
required_config = apps.nil? ?
|
32
|
+
required_config = apps.nil? ?
|
33
|
+
app[1]
|
34
|
+
: read_json_file(required_config_vars_json_file_path || default_config_vars_upsert_file_path)
|
33
35
|
app = app[0] if apps.nil?
|
34
36
|
|
35
37
|
if apps.nil? && sandbox && app != "neeto-dummy"
|
@@ -69,7 +71,9 @@ required_config_vars_with_project_keys_json_file_path, sandbox = false)
|
|
69
71
|
end
|
70
72
|
|
71
73
|
def inform_about_default_config_vars_file
|
72
|
-
if !apps.nil? &&
|
74
|
+
if !apps.nil? &&
|
75
|
+
required_config_vars_with_project_keys_json_file_path.nil? && required_config_vars_json_file_path.nil?
|
76
|
+
|
73
77
|
ui.info("Upserting config vars from the \"neetob/data/config-vars-upsert.json\" file")
|
74
78
|
end
|
75
79
|
end
|
@@ -18,11 +18,11 @@ module Neetob
|
|
18
18
|
|
19
19
|
def run
|
20
20
|
matching_apps = find_all_matching_apps(apps, :heroku, sandbox)
|
21
|
-
rails_runner_command = "
|
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|
|
24
24
|
ui.info("\n Working on #{app}\n")
|
25
|
-
output =
|
25
|
+
output = `heroku run "#{heroku_command}" -a #{app}`
|
26
26
|
unless $?.success?
|
27
27
|
ui.error("There is a problem in accessing the app with name \"#{app}\" in your account.")
|
28
28
|
ui.error("Please check the specified app name and ensure you're authorized to view that app.")
|
@@ -17,10 +17,12 @@ module Neetob
|
|
17
17
|
option :apps, type: :array, aliases: "-a", default: ["*"], desc: "Github app names. Can be matched using the '*' wildcard. Example: \"neeto*\" \"neeto-cal-web\""
|
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
|
20
22
|
def commits
|
21
23
|
Commits.new(
|
22
24
|
options[:author], options[:duration], options[:apps],
|
23
|
-
options[:sandbox]).run
|
25
|
+
options[:sandbox], options[:all_neeto_repos]).run
|
24
26
|
end
|
25
27
|
end
|
26
28
|
end
|
@@ -1,19 +1,25 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
3
|
+
require "chronic"
|
4
|
+
require "active_support/core_ext/numeric/time"
|
5
|
+
|
6
|
+
require_relative "../github/base"
|
4
7
|
|
5
8
|
module Neetob
|
6
9
|
class CLI
|
7
10
|
module Users
|
8
|
-
class Commits < Base
|
9
|
-
|
11
|
+
class Commits < Github::Base
|
12
|
+
include ActionView::Helpers::DateHelper
|
13
|
+
|
14
|
+
attr_accessor :sandbox, :apps, :author, :duration, :all_neeto_repos
|
10
15
|
|
11
|
-
def initialize(author, duration, apps = ["*"], sandbox = false)
|
16
|
+
def initialize(author, duration, apps = ["*"], sandbox = false, all_neeto_repos = false)
|
12
17
|
super()
|
13
18
|
@sandbox = sandbox
|
14
19
|
@apps = apps
|
15
20
|
@author = author
|
16
21
|
@duration = duration
|
22
|
+
@all_neeto_repos = all_neeto_repos
|
17
23
|
end
|
18
24
|
|
19
25
|
def run
|
@@ -26,38 +32,49 @@ module Neetob
|
|
26
32
|
private
|
27
33
|
|
28
34
|
def build_commit_rows
|
29
|
-
find_all_matching_apps(apps, :github, sandbox, true).map do |app|
|
35
|
+
commits = find_all_matching_apps(apps, :github, sandbox, true, all_neeto_repos).map do |app|
|
30
36
|
commits = commits_within_range(app)
|
31
|
-
if commits
|
32
|
-
ui.
|
37
|
+
if commits&.empty?
|
38
|
+
ui.info("No commits found in \"#{app}\" for the given author and duration.")
|
33
39
|
next
|
34
40
|
end
|
35
|
-
|
36
|
-
|
41
|
+
ui.success("Commits found in \"#{app}\".\n")
|
42
|
+
commits
|
37
43
|
end
|
44
|
+
sorted_commits = commits.compact.flatten.sort_by { |obj| obj.dig(:commit, :author, :date) }.reverse
|
45
|
+
build_table_rows(sorted_commits)
|
38
46
|
end
|
39
47
|
|
40
48
|
def commits_within_range(app)
|
41
|
-
|
49
|
+
fetch_commits(app, 1)
|
42
50
|
end
|
43
51
|
|
44
|
-
def build_table_rows(
|
45
|
-
commits.
|
52
|
+
def build_table_rows(commits)
|
53
|
+
commits.map do |commit|
|
54
|
+
app = commit[:html_url].split("/")[4]
|
55
|
+
commit_id = commit[:sha]
|
56
|
+
email = commit.dig(:commit, :author, :email)
|
57
|
+
time = distance_of_time_in_words(commit.dig(:commit, :author, :date), Time.current) + " ago"
|
58
|
+
date = commit.dig(:commit, :author, :date).strftime("%B %d, %Y")
|
59
|
+
title = commit.dig(:commit, :message).split("\n")[0]
|
60
|
+
html_table_row(app, commit_id, email, time, date, title)
|
61
|
+
end
|
46
62
|
end
|
47
63
|
|
48
64
|
def app_name_without_org_suffix(app)
|
49
65
|
app.split("/")[1]
|
50
66
|
end
|
51
67
|
|
52
|
-
def html_table_row(app,
|
53
|
-
starting_7_characters_of_commit =
|
68
|
+
def html_table_row(app, commit_id, email, time, date, title)
|
69
|
+
starting_7_characters_of_commit = commit_id[0..6]
|
54
70
|
"<tr>
|
55
|
-
<td class='commit'><a href='https://github.com/#{app}/commit/#{
|
56
|
-
|
57
|
-
<td class='project'>#{
|
58
|
-
<td class='email'>#{email}</td>
|
71
|
+
<td class='commit'><a href='https://github.com/bigbinary/#{app}/commit/#{commit_id}'
|
72
|
+
target='_blank'>#{starting_7_characters_of_commit}</a></td>
|
73
|
+
<td class='project'>#{app}</td>
|
59
74
|
<td class='time'>#{time}</td>
|
60
75
|
<td class='title'>#{title}</td>
|
76
|
+
<td class='time'>#{date}</td>
|
77
|
+
<td class='email'>#{email}</td>
|
61
78
|
</tr>"
|
62
79
|
end
|
63
80
|
|
@@ -66,8 +83,10 @@ module Neetob
|
|
66
83
|
<html>
|
67
84
|
<body>
|
68
85
|
<style>
|
69
|
-
|
86
|
+
body{
|
70
87
|
font-family: arial, sans-serif;
|
88
|
+
}
|
89
|
+
table {
|
71
90
|
border-collapse: collapse;
|
72
91
|
width: 100%;
|
73
92
|
}
|
@@ -95,16 +114,25 @@ module Neetob
|
|
95
114
|
.title {
|
96
115
|
color: lightcoral
|
97
116
|
}
|
117
|
+
.info{
|
118
|
+
font-size: larger;
|
119
|
+
margin-bottom: 10px;
|
120
|
+
}
|
98
121
|
</style>
|
122
|
+
<div class='info'>
|
123
|
+
Github user id: <strong>#{author}</strong> <br/>
|
124
|
+
Duration: <strong>#{duration}</strong>
|
125
|
+
</div>
|
99
126
|
<table>
|
100
127
|
<tr>
|
101
128
|
<th>Commit</th>
|
102
|
-
<th>
|
103
|
-
<th>Email</th>
|
129
|
+
<th>Repo</th>
|
104
130
|
<th>Created at</th>
|
105
131
|
<th>Title</th>
|
132
|
+
<th>Commited on</th>
|
133
|
+
<th>Email</th>
|
106
134
|
</tr>
|
107
|
-
#{table_rows
|
135
|
+
#{table_rows&.compact&.empty? ? "<tr><td>No commits found in the given duration</td></tr>" : table_rows.join}
|
108
136
|
</table>
|
109
137
|
</body>
|
110
138
|
</html>"
|
@@ -119,6 +147,27 @@ module Neetob
|
|
119
147
|
def open_html_file_in_default_system_application
|
120
148
|
`open ./commits.html`
|
121
149
|
end
|
150
|
+
|
151
|
+
def since_duration(duration)
|
152
|
+
Chronic.parse(duration.split(".").join(" ") + " ago")&.iso8601
|
153
|
+
end
|
154
|
+
|
155
|
+
def fetch_commits(app, page = 1)
|
156
|
+
begin
|
157
|
+
commits = client.commits(
|
158
|
+
app, "main",
|
159
|
+
{ author: author, since: since_duration(duration), per_page: 100, page: page })
|
160
|
+
rescue => exception
|
161
|
+
ui.error(exception.message)
|
162
|
+
commits = []
|
163
|
+
end
|
164
|
+
|
165
|
+
if commits.length == 100
|
166
|
+
commits + fetch_commits(app, page + 1)
|
167
|
+
else
|
168
|
+
commits
|
169
|
+
end
|
170
|
+
end
|
122
171
|
end
|
123
172
|
end
|
124
173
|
end
|
data/lib/neetob/cli.rb
CHANGED
@@ -33,8 +33,10 @@ 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
|
36
38
|
def make_repos_uptodate
|
37
|
-
FetchorupdateRepos::Execute.new(options[:sandbox]).run
|
39
|
+
FetchorupdateRepos::Execute.new(options[:sandbox], options[:all_neeto_repos]).run
|
38
40
|
end
|
39
41
|
end
|
40
42
|
end
|
data/lib/neetob/version.rb
CHANGED
data/neetob.gemspec
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "lib/neetob/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "neetob"
|
7
|
+
spec.version = Neetob::VERSION
|
8
|
+
spec.authors = ["Udai Gupta"]
|
9
|
+
spec.email = ["udaigupta19311@gmail.com"]
|
10
|
+
|
11
|
+
spec.summary = "Provides a set of helper scripts for Github and Heroku."
|
12
|
+
spec.description = "This gem gives different commands for interacting with Github and Heroku instances of existing neeto repos."
|
13
|
+
spec.homepage = "https://github.com/bigbinary/neetob"
|
14
|
+
spec.license = "MIT"
|
15
|
+
spec.required_ruby_version = ">= 3.0.0"
|
16
|
+
|
17
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
18
|
+
spec.metadata["source_code_uri"] = "https://github.com/bigbinary/neetob"
|
19
|
+
spec.metadata["changelog_uri"] = "https://github.com/bigbinary/neetob/blob/main/CHANGELOG.md"
|
20
|
+
|
21
|
+
# Specify which files should be added to the gem when it is released.
|
22
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
23
|
+
spec.files = Dir.chdir(__dir__) do
|
24
|
+
`git ls-files -z`.split("\x0").reject do |f|
|
25
|
+
(f == __FILE__) || f.match(%r{\A(?:(?:bin|test|spec|features)/|\.(?:git|travis|circleci)|appveyor)})
|
26
|
+
end
|
27
|
+
end
|
28
|
+
spec.bindir = "exe"
|
29
|
+
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
|
30
|
+
spec.require_paths = ["lib"]
|
31
|
+
|
32
|
+
# Must have deps
|
33
|
+
spec.add_dependency "thor", "~> 1.2.1" # for cli
|
34
|
+
spec.add_dependency "octokit", "~> 4.0" # for github client
|
35
|
+
spec.add_dependency "terminal-table", "~> 3.0.2" # for building cli table
|
36
|
+
spec.add_dependency "launchy", "~> 2.5.0" # for opening in browser
|
37
|
+
spec.add_dependency "dotenv", "~> 2.8.1" # for loading env variables
|
38
|
+
|
39
|
+
# To add the files from submodules
|
40
|
+
`git submodule --quiet foreach pwd`.split($\).each do |submodule_path|
|
41
|
+
Dir.chdir(submodule_path) do
|
42
|
+
required_submodule_files = `git ls-files -z`
|
43
|
+
.split("\x0")
|
44
|
+
.select { |file| file.match("lib/neeto_compliance*|data/*") }
|
45
|
+
.map { |file| "#{submodule_path}/#{file}" }
|
46
|
+
.map { |file| file.gsub "#{File.dirname(__FILE__)}/", "" }
|
47
|
+
spec.files += required_submodule_files
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
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.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Udai Gupta
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-02-
|
11
|
+
date: 2023-02-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|
@@ -94,68 +94,18 @@ files:
|
|
94
94
|
- ".rubocop.yml"
|
95
95
|
- ".ruby-version"
|
96
96
|
- ".semaphore/semaphore.yml"
|
97
|
-
- "/Users/chiragshah/Workspace/bigbinary/neeto/neetob/neeto_compliance/lib/neeto_compliance/github_access.rb"
|
98
|
-
- "/Users/chiragshah/Workspace/bigbinary/neeto/neetob/neeto_compliance/lib/neeto_compliance/neeto_apps.rb"
|
99
|
-
- "/Users/chiragshah/Workspace/bigbinary/neeto/neetob/neeto_compliance/lib/neeto_compliance/neeto_commons.rb"
|
100
|
-
- "/Users/chiragshah/Workspace/bigbinary/neeto/neetob/neeto_compliance/lib/neeto_compliance/runner.rb"
|
101
|
-
- "/Users/chiragshah/Workspace/bigbinary/neeto/neetob/neeto_compliance/lib/neeto_compliance/skippable.rb"
|
102
|
-
- "/Users/chiragshah/Workspace/bigbinary/neeto/neetob/neeto_compliance/lib/neeto_compliance/sync_neeto_commons.rb"
|
103
|
-
- "/Users/chiragshah/Workspace/bigbinary/neeto/neetob/neeto_compliance/lib/neeto_compliance/sync_neeto_commons/sync_bin.rb"
|
104
|
-
- "/Users/chiragshah/Workspace/bigbinary/neeto/neetob/neeto_compliance/lib/neeto_compliance/sync_neeto_commons/sync_formatters.rb"
|
105
|
-
- "/Users/chiragshah/Workspace/bigbinary/neeto/neetob/neeto_compliance/lib/neeto_compliance/sync_neeto_commons/sync_husky.rb"
|
106
|
-
- "/Users/chiragshah/Workspace/bigbinary/neeto/neetob/neeto_compliance/lib/neeto_compliance/sync_neeto_commons/sync_misc.rb"
|
107
|
-
- "/Users/chiragshah/Workspace/bigbinary/neeto/neetob/neeto_compliance/lib/neeto_compliance/sync_neeto_commons/sync_test_support.rb"
|
108
|
-
- "/Users/chiragshah/Workspace/bigbinary/neeto/neetob/neeto_compliance/lib/neeto_compliance/verifiers/auto_update_prs_with_latest_master_verifier.rb"
|
109
|
-
- "/Users/chiragshah/Workspace/bigbinary/neeto/neetob/neeto_compliance/lib/neeto_compliance/verifiers/base.rb"
|
110
|
-
- "/Users/chiragshah/Workspace/bigbinary/neeto/neetob/neeto_compliance/lib/neeto_compliance/verifiers/bundler_version_verifier.rb"
|
111
|
-
- "/Users/chiragshah/Workspace/bigbinary/neeto/neetob/neeto_compliance/lib/neeto_compliance/verifiers/circleci_config_verifier.rb"
|
112
|
-
- "/Users/chiragshah/Workspace/bigbinary/neeto/neetob/neeto_compliance/lib/neeto_compliance/verifiers/common_gemfile_verifier.rb"
|
113
|
-
- "/Users/chiragshah/Workspace/bigbinary/neeto/neetob/neeto_compliance/lib/neeto_compliance/verifiers/common_initializers_verifier.rb"
|
114
|
-
- "/Users/chiragshah/Workspace/bigbinary/neeto/neetob/neeto_compliance/lib/neeto_compliance/verifiers/cypress_config_verifier.rb"
|
115
|
-
- "/Users/chiragshah/Workspace/bigbinary/neeto/neetob/neeto_compliance/lib/neeto_compliance/verifiers/cypress_plugins_index_verifier.rb"
|
116
|
-
- "/Users/chiragshah/Workspace/bigbinary/neeto/neetob/neeto_compliance/lib/neeto_compliance/verifiers/docker_file_dev_verifier.rb"
|
117
|
-
- "/Users/chiragshah/Workspace/bigbinary/neeto/neetob/neeto_compliance/lib/neeto_compliance/verifiers/environment_config_verifier.rb"
|
118
|
-
- "/Users/chiragshah/Workspace/bigbinary/neeto/neetob/neeto_compliance/lib/neeto_compliance/verifiers/gem_version_verifier.rb"
|
119
|
-
- "/Users/chiragshah/Workspace/bigbinary/neeto/neetob/neeto_compliance/lib/neeto_compliance/verifiers/gems_verifier_base.rb"
|
120
|
-
- "/Users/chiragshah/Workspace/bigbinary/neeto/neetob/neeto_compliance/lib/neeto_compliance/verifiers/gitignore_file_verifier.rb"
|
121
|
-
- "/Users/chiragshah/Workspace/bigbinary/neeto/neetob/neeto_compliance/lib/neeto_compliance/verifiers/jsconfig_verifier.rb"
|
122
|
-
- "/Users/chiragshah/Workspace/bigbinary/neeto/neetob/neeto_compliance/lib/neeto_compliance/verifiers/neeto_auth_gems_verifier.rb"
|
123
|
-
- "/Users/chiragshah/Workspace/bigbinary/neeto/neetob/neeto_compliance/lib/neeto_compliance/verifiers/neeto_commons_sync_verifier.rb"
|
124
|
-
- "/Users/chiragshah/Workspace/bigbinary/neeto/neetob/neeto_compliance/lib/neeto_compliance/verifiers/neeto_gems_version_verifier.rb"
|
125
|
-
- "/Users/chiragshah/Workspace/bigbinary/neeto/neetob/neeto_compliance/lib/neeto_compliance/verifiers/newrelic_verifier.rb"
|
126
|
-
- "/Users/chiragshah/Workspace/bigbinary/neeto/neetob/neeto_compliance/lib/neeto_compliance/verifiers/node_version_verifier.rb"
|
127
|
-
- "/Users/chiragshah/Workspace/bigbinary/neeto/neetob/neeto_compliance/lib/neeto_compliance/verifiers/package_dependencies_version_verifier.rb"
|
128
|
-
- "/Users/chiragshah/Workspace/bigbinary/neeto/neetob/neeto_compliance/lib/neeto_compliance/verifiers/package_json_verifier.rb"
|
129
|
-
- "/Users/chiragshah/Workspace/bigbinary/neeto/neetob/neeto_compliance/lib/neeto_compliance/verifiers/roles_verifier.rb"
|
130
|
-
- "/Users/chiragshah/Workspace/bigbinary/neeto/neetob/neeto_compliance/lib/neeto_compliance/verifiers/ruby_version_verifier.rb"
|
131
|
-
- "/Users/chiragshah/Workspace/bigbinary/neeto/neetob/neeto_compliance/lib/neeto_compliance/verifiers/semaphoreci_config_verifier.rb"
|
132
|
-
- "/Users/chiragshah/Workspace/bigbinary/neeto/neetob/neeto_compliance/lib/neeto_compliance/verifiers/sidekiq_queues_verifier.rb"
|
133
|
-
- "/Users/chiragshah/Workspace/bigbinary/neeto/neetob/neeto_compliance/lib/neeto_compliance/verifiers/simplecov_config_verifier.rb"
|
134
|
-
- "/Users/chiragshah/Workspace/bigbinary/neeto/neetob/neeto_compliance/lib/neeto_compliance/verifiers/sitemap_config_verifier.rb"
|
135
|
-
- "/Users/chiragshah/Workspace/bigbinary/neeto/neetob/neeto_compliance/lib/neeto_compliance/verifiers/slugignore_file_verifier.rb"
|
136
|
-
- "/Users/chiragshah/Workspace/bigbinary/neeto/neetob/neeto_compliance/lib/neeto_compliance/verifiers/sync_neeto_commons_verifier.rb"
|
137
|
-
- "/Users/chiragshah/Workspace/bigbinary/neeto/neetob/neeto_compliance/lib/neeto_compliance/verifiers/sync_neeto_commons_verifier/bin_files_verifier.rb"
|
138
|
-
- "/Users/chiragshah/Workspace/bigbinary/neeto/neetob/neeto_compliance/lib/neeto_compliance/verifiers/sync_neeto_commons_verifier/formatter_files_verifier.rb"
|
139
|
-
- "/Users/chiragshah/Workspace/bigbinary/neeto/neetob/neeto_compliance/lib/neeto_compliance/verifiers/sync_neeto_commons_verifier/husky_files_verifier.rb"
|
140
|
-
- "/Users/chiragshah/Workspace/bigbinary/neeto/neetob/neeto_compliance/lib/neeto_compliance/verifiers/sync_neeto_commons_verifier/misc_files_verifier.rb"
|
141
|
-
- "/Users/chiragshah/Workspace/bigbinary/neeto/neetob/neeto_compliance/lib/neeto_compliance/verifiers/sync_neeto_commons_verifier/test_support_files_verifier.rb"
|
142
|
-
- "/Users/chiragshah/Workspace/bigbinary/neeto/neetob/neeto_compliance/lib/neeto_compliance/verifiers/webpack_configuration_verifier.rb"
|
143
|
-
- "/Users/chiragshah/Workspace/bigbinary/neeto/neetob/neeto_compliance/lib/neeto_compliance/verifiers/webpacker_config_verifier.rb"
|
144
|
-
- "/Users/chiragshah/Workspace/bigbinary/neeto/neetob/neeto_compliance/lib/neeto_compliance/verifiers_list.rb"
|
145
|
-
- "/Users/chiragshah/Workspace/bigbinary/neeto/neetob/neeto_compliance/lib/neeto_compliance/version.rb"
|
146
97
|
- CHANGELOG.md
|
147
98
|
- CODE_OF_CONDUCT.md
|
148
99
|
- Gemfile
|
149
100
|
- Gemfile.lock
|
150
|
-
- LICENSE.txt
|
151
101
|
- README.md
|
152
102
|
- Rakefile
|
103
|
+
- bookmarks.md
|
153
104
|
- data/branch-protection-rules.json
|
154
105
|
- data/config-vars-audit.json
|
155
106
|
- data/config-vars-list.json
|
156
107
|
- data/config-vars-upsert.json
|
157
108
|
- data/github-labels.json
|
158
|
-
- env.sample
|
159
109
|
- exe/neetob
|
160
110
|
- install.sh
|
161
111
|
- lib/neetob.rb
|
@@ -204,6 +154,7 @@ files:
|
|
204
154
|
- lib/neetob/exception_handler.rb
|
205
155
|
- lib/neetob/utils.rb
|
206
156
|
- lib/neetob/version.rb
|
157
|
+
- neetob.gemspec
|
207
158
|
- overcommit.yml
|
208
159
|
- scripts/delete_unused_assets.rb
|
209
160
|
homepage: https://github.com/bigbinary/neetob
|
@@ -213,7 +164,7 @@ metadata:
|
|
213
164
|
homepage_uri: https://github.com/bigbinary/neetob
|
214
165
|
source_code_uri: https://github.com/bigbinary/neetob
|
215
166
|
changelog_uri: https://github.com/bigbinary/neetob/blob/main/CHANGELOG.md
|
216
|
-
post_install_message:
|
167
|
+
post_install_message:
|
217
168
|
rdoc_options: []
|
218
169
|
require_paths:
|
219
170
|
- lib
|
@@ -229,7 +180,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
229
180
|
version: '0'
|
230
181
|
requirements: []
|
231
182
|
rubygems_version: 3.2.33
|
232
|
-
signing_key:
|
183
|
+
signing_key:
|
233
184
|
specification_version: 4
|
234
185
|
summary: Provides a set of helper scripts for Github and Heroku.
|
235
186
|
test_files: []
|