neetob 0.2.7 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +19 -0
- data/Gemfile.lock +2 -2
- data/README.md +13 -76
- data/docs/development.md +53 -0
- data/docs/testing.md +7 -0
- data/lib/neetob/cli/code/audit.rb +56 -0
- data/lib/neetob/cli/code/commands.rb +18 -0
- data/lib/neetob/cli/fetchorupdate_repos/execute.rb +20 -20
- data/lib/neetob/cli/github/gems/release.rb +1 -1
- data/lib/neetob/cli/github/make_pr/base.rb +2 -2
- data/lib/neetob/cli/github/make_pr/compliance_fix.rb +13 -2
- data/lib/neetob/cli/github/make_pr/script.rb +1 -1
- data/lib/neetob/cli/users/commands.rb +1 -1
- data/lib/neetob/cli.rb +7 -1
- data/lib/neetob/version.rb +1 -1
- metadata +6 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c24a5c688914c96c2ab4652e673124a9f794e1cdb57ca86e606e61134717b015
|
4
|
+
data.tar.gz: b66c79be8be99068e154fdd811556fa3a6dc947f9f8ac232fdc82654241236b5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d07b6d3b394a6ce90d6feaa8031c506bb49be5bdcf076761cdc1c55b9e555400cc9fafdb766816de82d4bfbc438e8e8a3784c9c2c94d4ab49a3c66795f5f4da0
|
7
|
+
data.tar.gz: 8fbfe0585f64116cd3404873d19a7518e034ffe250d789c5775bc6186c808bcf88c1407e10cbca5c73fe1333ef069642095577c3142054ef2fc6260cd90ee33b
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,24 @@
|
|
1
1
|
## [Unreleased]
|
2
2
|
|
3
|
+
### [0.3.1](https://www.github.com/bigbinary/neetob/compare/v0.3.0...v0.3.1) (2023-03-23)
|
4
|
+
|
5
|
+
|
6
|
+
### Bug Fixes
|
7
|
+
|
8
|
+
* Cleanup documentation ([#226](https://www.github.com/bigbinary/neetob/issues/226)) ([c20203b](https://www.github.com/bigbinary/neetob/commit/c20203bf31b0a08e9d22d8cb32295e840c3a1afe))
|
9
|
+
|
10
|
+
## [0.3.0](https://www.github.com/bigbinary/neetob/compare/v0.2.7...v0.3.0) (2023-03-23)
|
11
|
+
|
12
|
+
|
13
|
+
### Features
|
14
|
+
|
15
|
+
* Added command to audit neeto products db-schema. ([#230](https://www.github.com/bigbinary/neetob/issues/230)) ([1401abc](https://www.github.com/bigbinary/neetob/commit/1401abc77e3dedfbf156266a328de7a3d4fe6bb0))
|
16
|
+
|
17
|
+
|
18
|
+
### Bug Fixes
|
19
|
+
|
20
|
+
* Enhanced compliance fix command ([#225](https://www.github.com/bigbinary/neetob/issues/225)) ([a41c95c](https://www.github.com/bigbinary/neetob/commit/a41c95c435173f331a2872ca5a9192c38fc04e22))
|
21
|
+
|
3
22
|
### [0.2.7](https://www.github.com/bigbinary/neetob/compare/v0.2.6...v0.2.7) (2023-03-16)
|
4
23
|
|
5
24
|
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
neetob (0.
|
4
|
+
neetob (0.3.1)
|
5
5
|
dotenv (~> 2.8.1)
|
6
6
|
launchy (~> 2.5.0)
|
7
7
|
octokit (~> 4.0)
|
@@ -164,7 +164,7 @@ GEM
|
|
164
164
|
method_source (~> 1.0)
|
165
165
|
public_suffix (5.0.0)
|
166
166
|
racc (1.6.1)
|
167
|
-
rack (2.2.6.
|
167
|
+
rack (2.2.6.4)
|
168
168
|
rack-test (2.0.2)
|
169
169
|
rack (>= 1.3)
|
170
170
|
rails (7.0.4)
|
data/README.md
CHANGED
@@ -6,8 +6,7 @@ The `neetob` gem gives a different set of commands for interacting with Github r
|
|
6
6
|
|
7
7
|
1. [Usage](#usage)
|
8
8
|
1. [Installing neetob for use](#installing-neetob-for-use)
|
9
|
-
2. [
|
10
|
-
3. [Gem release](#gem-release)
|
9
|
+
2. [Installing neetob for development](docs/development.md)
|
11
10
|
2. [Source of truth](#source-of-truth)
|
12
11
|
3. [Working with GitHub](#working-with-github)
|
13
12
|
1. [Issues](#issues)
|
@@ -17,7 +16,7 @@ The `neetob` gem gives a different set of commands for interacting with Github r
|
|
17
16
|
5. [Make PR](#make-pr)
|
18
17
|
6. [Gems](#gems)
|
19
18
|
7. [Login](#login)
|
20
|
-
|
19
|
+
4. [Working with Heroku](#working-with-heroku)
|
21
20
|
1. [Config Vars](#config-vars)
|
22
21
|
2. [Access](#access)
|
23
22
|
3. [Execute](#execute)
|
@@ -27,7 +26,7 @@ The `neetob` gem gives a different set of commands for interacting with Github r
|
|
27
26
|
6. [Make Repos Uptodate](#make-repos-uptodate)
|
28
27
|
7. [Working with local Repos](#working-with-local-repos)
|
29
28
|
1. [ls](#ls)
|
30
|
-
8. [Testing](
|
29
|
+
8. [Testing](docs/testing.md)
|
31
30
|
|
32
31
|
## Usage
|
33
32
|
|
@@ -67,61 +66,6 @@ Options:
|
|
67
66
|
|
68
67
|
The commands within `neetob` should be used with caution, as improper usage may result in unintended consequences, and some actions may not be reversible. By default, all commands will be executed in non-sandbox mode.
|
69
68
|
|
70
|
-
### For development
|
71
|
-
|
72
|
-
Clone the repository onto your system using the following command:
|
73
|
-
|
74
|
-
```sh
|
75
|
-
git clone https://github.com/bigbinary/neetob.git
|
76
|
-
```
|
77
|
-
|
78
|
-
Navigate to the root of the application directory.
|
79
|
-
|
80
|
-
```sh
|
81
|
-
cd neetob
|
82
|
-
```
|
83
|
-
|
84
|
-
To check and use the latest changes in the local repository install `neetob` like so:
|
85
|
-
|
86
|
-
```sh
|
87
|
-
bin/setup
|
88
|
-
```
|
89
|
-
|
90
|
-
We can use, check or debug the `neetob` locally by directly invoking the `neetob` class like so:
|
91
|
-
|
92
|
-
```sh
|
93
|
-
ruby exe/neeetob
|
94
|
-
```
|
95
|
-
|
96
|
-
#### Conventional commit messages
|
97
|
-
|
98
|
-
In `neetob` we are using the Google's [release please](https://github.com/googleapis/release-please) Github action to auto update the version and release the latest gem.
|
99
|
-
|
100
|
-
In order to make this action work we have to use the [conventional commit messages](https://www.conventionalcommits.org/en/v1.0.0/).
|
101
|
-
|
102
|
-
The Conventional commits specification is a lightweight convention on top of commit messages. It provides an easy set of rules for creating an explicit commit history.
|
103
|
-
|
104
|
-
Generally, we use three types of suffix in the commit messages that are as follows:
|
105
|
-
|
106
|
-
1. `fix:` for the commit that fixes a bug in the codebase. This updates the third digit in the version. For example, `0.1.0` version will be updated to `0.1.1`.
|
107
|
-
|
108
|
-
2. `feat:` for the commit that introduces a new feature to the codebase. This updates the second digit in the version. For example, `0.1.0` version will be updated to `0.2.0`.
|
109
|
-
|
110
|
-
3. `BREAKING CHANGE:` for the commit that introduces a breaking API change. This updates the first digit in the version. For example, `0.1.0` version will be updated to `1.0.0`.
|
111
|
-
|
112
|
-
For more details please refer [official docs](https://www.conventionalcommits.org/en/v1.0.0/) from Conventional commits.
|
113
|
-
|
114
|
-
In `neetob` we use "squash and merge" option while merging the PR. So we have to update the commit message while squash and merge so that Github action can track that merge commit.
|
115
|
-
|
116
|
-
For example:
|
117
|
-
|
118
|
-
![Commit message update](images/commit-message-update.png)
|
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
|
-
|
125
69
|
## Source of truth
|
126
70
|
|
127
71
|
This [list of repos](https://github.com/bigbinary/neeto-compliance/blob/main/data/neeto_repos.json) is used as the "source of truth".
|
@@ -178,10 +122,10 @@ neetob github labels show --name priority --repos "neeto-*-staging"
|
|
178
122
|
|
179
123
|
# Changes the name of the label
|
180
124
|
neetob github labels update --old-name "High Priority" --new-name \
|
181
|
-
"high-priority" --all
|
125
|
+
"high-priority" --repos "all"
|
182
126
|
|
183
127
|
# Updates and inserts all the labels mentioned in the file "data/github-labels.json"
|
184
|
-
neetob github labels upsert --all
|
128
|
+
neetob github labels upsert --repos "all"
|
185
129
|
|
186
130
|
# Accepts a different JSON file using `path` option
|
187
131
|
neetob github labels upsert --path ~/Desktop/labels.json --repos "neeto-*-staging"
|
@@ -189,7 +133,7 @@ neetob github labels upsert --path ~/Desktop/labels.json --repos "neeto-*-stagin
|
|
189
133
|
# Upsert a single label using `name`, `color`, and `description` options
|
190
134
|
# No `#` is required while adding `color`
|
191
135
|
neetob github labels upsert --name UI --color 8250df --description \
|
192
|
-
"UI work needed" --all
|
136
|
+
"UI work needed" --repos "all"
|
193
137
|
|
194
138
|
# Deletes the given labels from the Github repos
|
195
139
|
neetob github labels delete --labels "High Priority" "Priority 1" "bug" \
|
@@ -248,13 +192,13 @@ neetob github protect_branch --branch main --path ~/Desktop/branch-protection-ru
|
|
248
192
|
--repos "neeto-*-staging"
|
249
193
|
```
|
250
194
|
|
251
|
-
We can also
|
195
|
+
We can also pass the value `all` to the option `--repos` with the above mentioned command so that the
|
252
196
|
branch protection rules can be updated for
|
253
197
|
all [neeto repos](https://github.com/bigbinary/neeto-compliance/blob/main/data/neeto_repos.json).
|
254
198
|
|
255
199
|
```sh
|
256
200
|
neetob github protect_branch --branch main --path ~/Desktop/branch-protection-rules.json \
|
257
|
-
--all
|
201
|
+
--repos "all"
|
258
202
|
```
|
259
203
|
|
260
204
|
**Note:** Unfortunately, utilizing the Github API, we are unable to update the `Require deployments to succeed before merging` rule, as it is currently not defined as a parameter within the API. For further information on available options to update different branch protection rules, kindly refer to the official Github [documentation](https://docs.github.com/en/rest/branches/branch-protection#update-branch-protection).
|
@@ -432,8 +376,8 @@ neetob users commits --author udai1931 --duration 6.months
|
|
432
376
|
# List commits for a specific product using `--apps` option
|
433
377
|
neetob users commits --author udai1931 --duration 6.months --apps neeto-kb-web
|
434
378
|
|
435
|
-
# List commits for all neeto repos
|
436
|
-
neetob users commits --author udai1931 --duration 6.months --all
|
379
|
+
# List commits for all neeto repos by passing the value `all` to`--apps` option
|
380
|
+
neetob users commits --author udai1931 --duration 6.months --apps "all"
|
437
381
|
```
|
438
382
|
|
439
383
|
## Make Repos Uptodate
|
@@ -443,8 +387,9 @@ The `make_repos_uptodate` command updates all neeto repos.
|
|
443
387
|
```sh
|
444
388
|
neetob make_repos_uptodate
|
445
389
|
|
446
|
-
# Update all neeto repos
|
447
|
-
neetob make_repos_uptodate --all
|
390
|
+
# Update all neeto repos by passing the value `all` to`--repos` option
|
391
|
+
neetob make_repos_uptodate --repos "all"
|
392
|
+
|
448
393
|
```
|
449
394
|
|
450
395
|
Executing the above mentioned command will check and clone all the missing neeto repos in the current working directory and will update all of them to the latest version. After the execution of command the directories will look something like this:
|
@@ -473,11 +418,3 @@ neetob local ls --dir public --apps "neeto-*-web"
|
|
473
418
|
# List files in a nested directory
|
474
419
|
neetob local ls --dir app/controllers --apps "neeto-*-web"
|
475
420
|
```
|
476
|
-
|
477
|
-
## Testing
|
478
|
-
|
479
|
-
For testing `github` commands use - [neeto-dummy](https://github.com/bigbinary/neeto-dummy) repo.
|
480
|
-
|
481
|
-
For testing `heroku` commands use - [neeto-dummy](https://dashboard.heroku.com/apps/neeto-dummy) app.
|
482
|
-
|
483
|
-
**Note:** Contact your respective Team Lead if you don't have access.
|
data/docs/development.md
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
### Installing neetob for development
|
2
|
+
|
3
|
+
Clone the repository onto your system using the following command:
|
4
|
+
|
5
|
+
```sh
|
6
|
+
git clone https://github.com/bigbinary/neetob.git
|
7
|
+
```
|
8
|
+
|
9
|
+
Navigate to the root of the application directory.
|
10
|
+
|
11
|
+
```sh
|
12
|
+
cd neetob
|
13
|
+
```
|
14
|
+
|
15
|
+
To check and use the latest changes in the local repository install `neetob` like so:
|
16
|
+
|
17
|
+
```sh
|
18
|
+
bin/setup
|
19
|
+
```
|
20
|
+
|
21
|
+
We can use, check or debug the `neetob` locally by directly invoking the `neetob` class like so:
|
22
|
+
|
23
|
+
```sh
|
24
|
+
ruby exe/neeetob
|
25
|
+
```
|
26
|
+
|
27
|
+
### Conventional commit messages
|
28
|
+
|
29
|
+
In `neetob` we are using the Google's [release please](https://github.com/googleapis/release-please) Github action to auto update the version and release the latest gem.
|
30
|
+
|
31
|
+
In order to make this action work we have to use the [conventional commit messages](https://www.conventionalcommits.org/en/v1.0.0/).
|
32
|
+
|
33
|
+
The Conventional commits specification is a lightweight convention on top of commit messages. It provides an easy set of rules for creating an explicit commit history.
|
34
|
+
|
35
|
+
Generally, we use three types of suffix in the commit messages that are as follows:
|
36
|
+
|
37
|
+
1. `fix:` for the commit that fixes a bug in the codebase. This updates the third digit in the version. For example, `0.1.0` version will be updated to `0.1.1`.
|
38
|
+
|
39
|
+
2. `feat:` for the commit that introduces a new feature to the codebase. This updates the second digit in the version. For example, `0.1.0` version will be updated to `0.2.0`.
|
40
|
+
|
41
|
+
3. `BREAKING CHANGE:` for the commit that introduces a breaking API change. This updates the first digit in the version. For example, `0.1.0` version will be updated to `1.0.0`.
|
42
|
+
|
43
|
+
For more details please refer [official docs](https://www.conventionalcommits.org/en/v1.0.0/) from Conventional commits.
|
44
|
+
|
45
|
+
In `neetob` we use "squash and merge" option while merging the PR. So we have to update the commit message while squash and merge so that Github action can track that merge commit.
|
46
|
+
|
47
|
+
For example:
|
48
|
+
|
49
|
+
![Commit message update](../images/commit-message-update.png)
|
50
|
+
|
51
|
+
### Gem release
|
52
|
+
|
53
|
+
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).
|
data/docs/testing.md
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
# Testing instructions
|
2
|
+
|
3
|
+
For testing `github` commands use - [neeto-dummy](https://github.com/bigbinary/neeto-dummy) repo.
|
4
|
+
|
5
|
+
For testing `heroku` commands use - [neeto-dummy](https://dashboard.heroku.com/apps/neeto-dummy) app.
|
6
|
+
|
7
|
+
**Note:** Contact your respective Team Lead if you don't have access.
|
@@ -0,0 +1,56 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "../github/base"
|
4
|
+
|
5
|
+
module Neetob
|
6
|
+
class CLI
|
7
|
+
module Code
|
8
|
+
class Audit < Github::Base
|
9
|
+
attr_accessor :sandbox, :apps
|
10
|
+
|
11
|
+
def initialize(apps, sandbox = false)
|
12
|
+
super()
|
13
|
+
@apps = apps
|
14
|
+
@sandbox = sandbox
|
15
|
+
end
|
16
|
+
|
17
|
+
def run
|
18
|
+
matching_apps = find_all_matching_apps_or_repos(apps, :github, sandbox)
|
19
|
+
ui.info("\nListing apps and their tables that doesn't have uuid as primary key type:-")
|
20
|
+
has_found_tables_without_uuid = false
|
21
|
+
matching_apps.each do |app|
|
22
|
+
begin
|
23
|
+
db_schema = Base64.decode64(client.contents(app, path: "./db/schema.rb").content)
|
24
|
+
tables_without_uuid = find_tables_without_uuid_as_primary_key(db_schema).compact
|
25
|
+
if !tables_without_uuid.nil?
|
26
|
+
has_found_tables_without_uuid = true
|
27
|
+
print_app_and_tables(app, tables_without_uuid)
|
28
|
+
end
|
29
|
+
rescue Octokit::NotFound
|
30
|
+
ui.error("There is no \"db/schema.rb\" file in the \"#{app}\" app.")
|
31
|
+
rescue StandardError => e
|
32
|
+
ExceptionHandler.new(e).process
|
33
|
+
end
|
34
|
+
end
|
35
|
+
ui.info("No apps found to have tables without uuid as primary key type") if !has_found_tables_without_uuid
|
36
|
+
end
|
37
|
+
|
38
|
+
private
|
39
|
+
|
40
|
+
def find_tables_without_uuid_as_primary_key(db_schema)
|
41
|
+
create_table_regex = /create_table.*?,\s*force:\s*:cascade\s*do\s*\|t\|/
|
42
|
+
db_schema.scan(create_table_regex).map do |create_table_line|
|
43
|
+
!create_table_line.include?("id: :uuid") ? create_table_line.scan(/"([^"]+)"/).flatten.first : nil
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
def print_app_and_tables(app, tables)
|
48
|
+
ui.info("\n#{app}:-")
|
49
|
+
tables.each do |table|
|
50
|
+
ui.say(" ↳#{table}")
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "thor"
|
4
|
+
require_relative "audit"
|
5
|
+
|
6
|
+
module Neetob
|
7
|
+
class CLI
|
8
|
+
module Code
|
9
|
+
class Commands < Thor
|
10
|
+
desc "audit", "Audit code base of neeto products to ensure they are properly maintained."
|
11
|
+
option :apps, type: :array, aliases: "-a", required: true, desc: "Neeto app names. Can be matched using the '*' wildcard. Example: \"neeto*\" \"neeto-cal-web\", also providing \"all\" as value matches all neeto product apps."
|
12
|
+
def audit
|
13
|
+
Audit.new(options[:apps], options[:sandbox]).run
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -6,46 +6,46 @@ module Neetob
|
|
6
6
|
class CLI
|
7
7
|
module FetchorupdateRepos
|
8
8
|
class Execute < Base
|
9
|
-
attr_accessor :sandbox, :
|
9
|
+
attr_accessor :sandbox, :repos
|
10
10
|
|
11
|
-
def initialize(sandbox = false,
|
11
|
+
def initialize(sandbox = false, repos = ["*"])
|
12
12
|
super()
|
13
13
|
@sandbox = sandbox
|
14
|
-
@
|
14
|
+
@repos = repos
|
15
15
|
end
|
16
16
|
|
17
17
|
def run
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
ui.info("\nWorking on #{
|
22
|
-
if directory_exists(
|
23
|
-
checkout_to_main_and_fetch_commits(
|
18
|
+
neeto_repos = find_all_matching_apps_or_repos(repos, :github, sandbox)
|
19
|
+
neeto_repos.each do |repo|
|
20
|
+
repo_name = repo.split("/").last
|
21
|
+
ui.info("\nWorking on #{repo_name}\n")
|
22
|
+
if directory_exists(repo_name)
|
23
|
+
checkout_to_main_and_fetch_commits(repo_name)
|
24
24
|
else
|
25
|
-
clone_repo(
|
25
|
+
clone_repo(repo_name)
|
26
26
|
end
|
27
27
|
end
|
28
28
|
end
|
29
29
|
|
30
|
-
def directory_exists(
|
31
|
-
File.directory?(
|
30
|
+
def directory_exists(repo_name)
|
31
|
+
File.directory?(repo_name)
|
32
32
|
end
|
33
33
|
|
34
|
-
def checkout_to_main_and_fetch_commits(
|
35
|
-
%x[ cd #{
|
34
|
+
def checkout_to_main_and_fetch_commits(repo_name)
|
35
|
+
%x[ cd #{repo_name} && git checkout main && git pull origin main ]
|
36
36
|
if $?.success?
|
37
|
-
puts "------Successfully pulled main branch of #{
|
37
|
+
puts "------Successfully pulled main branch of #{repo_name}------"
|
38
38
|
else
|
39
|
-
puts "------Unable to pull the main branch of #{
|
39
|
+
puts "------Unable to pull the main branch of #{repo_name} due to conflicts------"
|
40
40
|
end
|
41
41
|
end
|
42
42
|
|
43
|
-
def clone_repo(
|
44
|
-
`git clone git@github.com:bigbinary/#{
|
43
|
+
def clone_repo(repo_name)
|
44
|
+
`git clone git@github.com:bigbinary/#{repo_name}.git`
|
45
45
|
if $?.success?
|
46
|
-
puts "------Done cloning #{
|
46
|
+
puts "------Done cloning #{repo_name}------"
|
47
47
|
else
|
48
|
-
puts "------Failed cloning #{
|
48
|
+
puts "------Failed cloning #{repo_name}------"
|
49
49
|
end
|
50
50
|
end
|
51
51
|
end
|
@@ -28,8 +28,8 @@ module Neetob
|
|
28
28
|
repo.split("/").last
|
29
29
|
end
|
30
30
|
|
31
|
-
def
|
32
|
-
`git clone --quiet git@github.com:#{repo}.git /tmp/neetob/#{repo_name_without_org_suffix(repo)}`
|
31
|
+
def shallow_clone_repo_in_tmp_dir(repo)
|
32
|
+
`git clone --quiet --depth 1 git@github.com:#{repo}.git /tmp/neetob/#{repo_name_without_org_suffix(repo)}`
|
33
33
|
end
|
34
34
|
|
35
35
|
def add_commmit_and_push_changes(repo)
|
@@ -16,28 +16,32 @@ module Neetob
|
|
16
16
|
@repos = repos
|
17
17
|
@sandbox = sandbox
|
18
18
|
@should_fix_nanos = should_fix_nanos
|
19
|
+
@failed_repos = []
|
19
20
|
end
|
20
21
|
|
21
22
|
def run
|
22
23
|
matching_repos = should_fix_nanos ?
|
23
24
|
add_org_suffix(find_all_matching_gems) :
|
24
25
|
find_all_matching_apps_or_repos(repos, :github, sandbox)
|
26
|
+
@failed_repos = matching_repos
|
25
27
|
delete_and_create_temp_neetob_dir
|
26
28
|
matching_repos.each do |repo|
|
27
29
|
ui.info("\nWorking on #{repo}\n")
|
28
30
|
begin
|
29
|
-
|
31
|
+
shallow_clone_repo_in_tmp_dir(repo)
|
30
32
|
check_and_delete_remote_branch(repo)
|
31
33
|
bundle_install(repo)
|
32
34
|
fix_neeto_audit(repo)
|
33
35
|
ui.info(add_commmit_and_push_changes(repo))
|
34
36
|
delete_local_feature_branch(repo)
|
35
|
-
|
37
|
+
pull_request = client.create_pull_request(repo, "main", BRANCH_NAME, PR_TITLE)
|
36
38
|
ui.success("PR created in \"#{repo}\" project successfully.")
|
39
|
+
@failed_repos.delete(repo)
|
37
40
|
rescue StandardError => e
|
38
41
|
ExceptionHandler.new(e).process
|
39
42
|
end
|
40
43
|
end
|
44
|
+
print_failed_repos if @failed_repos.length > 0
|
41
45
|
`rm -rf /tmp/neetob`
|
42
46
|
end
|
43
47
|
|
@@ -50,6 +54,13 @@ module Neetob
|
|
50
54
|
def fix_neeto_audit(repo)
|
51
55
|
`#{cd_to_repo_in_tmp_dir(repo)} && bundle exec neeto-audit -a`
|
52
56
|
end
|
57
|
+
|
58
|
+
def print_failed_repos
|
59
|
+
ui.info("\nCompliance fix failed for repos:-")
|
60
|
+
@failed_repos.each do |repo|
|
61
|
+
ui.error(repo)
|
62
|
+
end
|
63
|
+
end
|
53
64
|
end
|
54
65
|
end
|
55
66
|
end
|
@@ -29,7 +29,7 @@ module Neetob
|
|
29
29
|
matching_repos.each do |repo|
|
30
30
|
ui.info("\n Working on #{repo} \n")
|
31
31
|
begin
|
32
|
-
|
32
|
+
shallow_clone_repo_in_tmp_dir(repo)
|
33
33
|
check_and_delete_remote_branch(repo)
|
34
34
|
update_script_file_permissions
|
35
35
|
execute_script(repo)
|
@@ -14,7 +14,7 @@ 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\", also providing \"all\" as value matches all neeto
|
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 apps."
|
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
20
|
def commits
|
data/lib/neetob/cli.rb
CHANGED
@@ -9,6 +9,7 @@ module Neetob
|
|
9
9
|
require_relative "cli/users/commands"
|
10
10
|
require_relative "cli/fetchorupdate_repos/execute"
|
11
11
|
require_relative "cli/local/commands"
|
12
|
+
require_relative "cli/code/commands"
|
12
13
|
|
13
14
|
class_option :sandbox,
|
14
15
|
{
|
@@ -32,9 +33,14 @@ module Neetob
|
|
32
33
|
desc "local", "Interact with the local neeto repos"
|
33
34
|
subcommand "local", Local::Commands
|
34
35
|
|
36
|
+
desc "code", "Interact with code base of neeto products"
|
37
|
+
subcommand "code", Code::Commands
|
38
|
+
|
35
39
|
desc "make_repos_uptodate", "Uptodate all neeto repos"
|
40
|
+
option :repos, type: :array, aliases: "-r", default: ["*"],
|
41
|
+
desc: "Github repo names. Can be matched using the '*' wildcard. Example: \"neeto*\" \"neeto-cal-web\", also providing \"all\" as value matches all neeto repos. Note: The default value is \"*\", hence all neeto repos would be affected."
|
36
42
|
def make_repos_uptodate
|
37
|
-
FetchorupdateRepos::Execute.new(options[:sandbox]).run
|
43
|
+
FetchorupdateRepos::Execute.new(options[:sandbox], options[:repos]).run
|
38
44
|
end
|
39
45
|
end
|
40
46
|
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.
|
4
|
+
version: 0.3.1
|
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-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|
@@ -106,12 +106,16 @@ files:
|
|
106
106
|
- data/config-vars-list.json
|
107
107
|
- data/config-vars-upsert.json
|
108
108
|
- data/github-labels.json
|
109
|
+
- docs/development.md
|
110
|
+
- docs/testing.md
|
109
111
|
- exe/neetob
|
110
112
|
- images/commit-message-update.png
|
111
113
|
- install.sh
|
112
114
|
- lib/neetob.rb
|
113
115
|
- lib/neetob/cli.rb
|
114
116
|
- lib/neetob/cli/base.rb
|
117
|
+
- lib/neetob/cli/code/audit.rb
|
118
|
+
- lib/neetob/cli/code/commands.rb
|
115
119
|
- lib/neetob/cli/fetchorupdate_repos/execute.rb
|
116
120
|
- lib/neetob/cli/github/auth.rb
|
117
121
|
- lib/neetob/cli/github/base.rb
|