wagemage 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: f596f9720293dd85e8a9b05965efb4cd8e3d51f8abfd9670153c7b5d9df7c8b7
4
+ data.tar.gz: 97dc290c57992232e89451c160e0fce05d84efacefad48da94e3cc5a8bcdddb6
5
+ SHA512:
6
+ metadata.gz: f208f9158b07a50220d32b98edfa36e66307a0bab44a0b508011e13aad1435458f39aa8aef2bd1a71db9bc17842921deb5710ec7bf45cbbd8c5443698db5f4c0
7
+ data.tar.gz: 9c32e145a8c1845bac31da49842224258376738b3d56cb872c12f0766d5177f6437e404a88e866530f40033b9a27e20e5cf2dbeac02a404c831de775e4609008
@@ -0,0 +1,18 @@
1
+ name: Tests
2
+ on: [push]
3
+ jobs:
4
+ test:
5
+ runs-on: ubuntu-latest
6
+ steps:
7
+ - name: Checkout Source Code
8
+ uses: actions/checkout@v1
9
+ - name: Install Ruby
10
+ uses: actions/setup-ruby@v1
11
+ with:
12
+ ruby_version: 2.6.x
13
+ - name: Install Dependencies
14
+ run: |
15
+ gem install bundler
16
+ bundle install
17
+ - name: Run Tests
18
+ run: bundle exec rake
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+ .rubocop-http*
@@ -0,0 +1,2 @@
1
+ inherit_from:
2
+ - https://raw.githubusercontent.com/workarea-commerce/workarea/master/.rubocop.yml
@@ -0,0 +1,7 @@
1
+ ---
2
+ sudo: false
3
+ language: ruby
4
+ cache: bundler
5
+ rvm:
6
+ - 2.4.6
7
+ before_install: gem install bundler -v 2.0.2
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at curt@portugly.com. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,15 @@
1
+ source "https://rubygems.org"
2
+ git_source(:github) { |repo| "https://github.com/#{repo}.git" }
3
+
4
+ # Specify your gem's dependencies in wagemage.gemspec
5
+ gemspec
6
+
7
+ gem 'pry', group: :development
8
+
9
+ gem "vcr", "~> 5.0"
10
+
11
+ gem "webmock", "~> 3.7"
12
+
13
+ gem "activesupport", "~> 6.0"
14
+
15
+ gem "mocha", "~> 1.11"
@@ -0,0 +1,74 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ wagemage (1.0.0)
5
+ colorize (~> 0.8)
6
+ octokit (~> 4.14)
7
+ slop (~> 4.7)
8
+
9
+ GEM
10
+ remote: https://rubygems.org/
11
+ specs:
12
+ activesupport (6.0.3.1)
13
+ concurrent-ruby (~> 1.0, >= 1.0.2)
14
+ i18n (>= 0.7, < 2)
15
+ minitest (~> 5.1)
16
+ tzinfo (~> 1.1)
17
+ zeitwerk (~> 2.2, >= 2.2.2)
18
+ addressable (2.7.0)
19
+ public_suffix (>= 2.0.2, < 5.0)
20
+ coderay (1.1.2)
21
+ colorize (0.8.1)
22
+ concurrent-ruby (1.1.6)
23
+ crack (0.4.3)
24
+ safe_yaml (~> 1.0.0)
25
+ faraday (1.1.0)
26
+ multipart-post (>= 1.2, < 3)
27
+ ruby2_keywords
28
+ hashdiff (1.0.1)
29
+ i18n (1.8.2)
30
+ concurrent-ruby (~> 1.0)
31
+ method_source (0.9.2)
32
+ minitest (5.14.0)
33
+ mocha (1.11.2)
34
+ multipart-post (2.1.1)
35
+ octokit (4.19.0)
36
+ faraday (>= 0.9)
37
+ sawyer (~> 0.8.0, >= 0.5.3)
38
+ pry (0.12.2)
39
+ coderay (~> 1.1.0)
40
+ method_source (~> 0.9.0)
41
+ public_suffix (4.0.3)
42
+ rake (12.3.3)
43
+ ruby2_keywords (0.0.2)
44
+ safe_yaml (1.0.5)
45
+ sawyer (0.8.2)
46
+ addressable (>= 2.3.5)
47
+ faraday (> 0.8, < 2.0)
48
+ slop (4.8.2)
49
+ thread_safe (0.3.6)
50
+ tzinfo (1.2.7)
51
+ thread_safe (~> 0.1)
52
+ vcr (5.1.0)
53
+ webmock (3.8.2)
54
+ addressable (>= 2.3.6)
55
+ crack (>= 0.3.2)
56
+ hashdiff (>= 0.4.0, < 2.0.0)
57
+ zeitwerk (2.3.0)
58
+
59
+ PLATFORMS
60
+ ruby
61
+
62
+ DEPENDENCIES
63
+ activesupport (~> 6.0)
64
+ bundler (~> 2.0)
65
+ minitest (~> 5.0)
66
+ mocha (~> 1.11)
67
+ pry
68
+ rake (~> 12.3.3)
69
+ vcr (~> 5.0)
70
+ wagemage!
71
+ webmock (~> 3.7)
72
+
73
+ BUNDLED WITH
74
+ 2.1.4
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2019 Curt Howard
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,242 @@
1
+ # Wagemage
2
+
3
+ A CLI for making changes to many GitHub-hosted git repositories.
4
+
5
+ [![Tests
6
+ Status](https://github.com/meowsus/wagemage/workflows/Tests/badge.svg)](https://github.com/meowsus/wagemage/actions)
7
+
8
+ ## Inspiration
9
+
10
+ At [Workarea](https://github.com/workarea-commerce) we have adopted a mutli-repo architecture for our platform and its plugins. Though separation is good, we have a lot of repositories. Sometimes we need to make changes across a great deal of our repositories. Sometimes we go a bit insane doing so.
11
+
12
+ We tried using [Gitbot](https://github.com/clever/gitbot) but found that their solution only accounts for making changes to the default branch of each repository. This does not work for us, since we support many versions of our plugins and have therefore adopted a branching strategy that works for us.
13
+
14
+ Wagemage was born out of fear of mundane tasks. Maybe it can help you too!
15
+
16
+ ## Installation
17
+
18
+ ```sh
19
+ gem install wagemage
20
+ ```
21
+
22
+ ## Dependencies
23
+
24
+ 1. A [Github account](https://github.com/join)
25
+ 1. A [Github Personal Access Token](https://help.github.com/en/github/authenticating-to-github/creating-a-personal-access-token-for-the-command-line) with `repo` permissions
26
+ 1. [Git](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git)
27
+ 1. [Hub](https://github.com/github/hub/releases)
28
+ 1. One or more repositories owned by you or an organization of which you are a member
29
+
30
+ ## What It Does
31
+
32
+ Wagemage hits the GitHub API to retrieve a list of repositories for the currently authenticated user. It can optionally be configured to search only within a given GitHub organization for this list of repositories.
33
+
34
+ Once the list of repositories is derived, Wagemage asks if you'd like to clone the list of repos it has found. If you agree, they are cloned to a temporary directory on your machine that will be cleaned up once the operation is complete, unless otherwise specified.
35
+
36
+ Upon cloning all of the repositories, each is searched for a list of remote branches. Wagemage can optionally be configured to search for remote branches that match a specific pattern.
37
+
38
+ Once the list of branches is derived, Wagemage asks you to review the list of repositories and their branches to make sure that they look correct to you before executing the supplied script on each branch.
39
+
40
+ For each branch in each repository the following occurs:
41
+ 1. The branch is checked out
42
+ 1. A new, "temporary" branch based on the branch that has been checked out is created in the format `[PREFIX]/[ORIGINAL_BRANCH_NAME]/[TIMESTAMP]`.
43
+ 1. The supplied script is executed and is passed arguments in this order:
44
+ 1. The current repo's directory, and
45
+ 1. The current repo's name, and
46
+ 1. The current branch name
47
+ 1. **The following steps are skipped if**
48
+ * the script exits with a _non-zero exit code_
49
+ * the script exits with a _zero exit code_ but no changes were made to the repository
50
+ 1. All changes are added to the Git stage
51
+ 1. A commit is made, based on the `stdout` of the supplied script
52
+ 1. **The following steps are skipped if the `--debug` option is supplied**
53
+ 1. The branch is pushed
54
+ 1. A pull request is automatically created, with configurable reviewers
55
+
56
+ ## Usage
57
+
58
+ ```sh
59
+ $ wagemage --help
60
+
61
+ usage: wagemage [options]
62
+ -h, --help print this help
63
+ -v, --version print the version
64
+ -o, --org github org
65
+ -r, --repo regex against which to match repo names
66
+ -b, --branch regex against which to match branches
67
+ -s, --script the script to run on each repo's branch
68
+ --first-branch operate only on the "oldest" branch
69
+ --reviewers array of github users to put on the PR
70
+ --branch-prefix prefix of the new branch
71
+ --debug don't push or issue PR, keep the tmp directory
72
+ ```
73
+
74
+ You will be prompted to enter your Github Personal Access Token at runtime, unless it is supplied as the value for the `WAGEMAGE_GITHUB_TOKEN` environment variable in your current session.
75
+
76
+ ### Options
77
+
78
+ #### `--org` (or `-o`)
79
+
80
+ Limits repository search to a specified GitHub organization.
81
+
82
+ ```
83
+ --org workarea-commerce
84
+ ```
85
+
86
+ * **Type**: String
87
+ * **Required?**: No
88
+ * **Default**: All repos available to the authenticated user
89
+
90
+ #### `--repo` (or `-r`)
91
+
92
+ Filter returned repositories based on name. Repository names are returned as full names: `meowsus/wagemage` instead of just `wagemage`.
93
+
94
+ ```
95
+ --repo '^workarea-commerce/workarea-' # returns all Workarea plugin repos
96
+ ```
97
+
98
+ * **Type**: Regex String
99
+ * **Required?**: No
100
+ * **Default**: None
101
+
102
+ #### `--branch` (or `-b`)
103
+
104
+ Filter available remote branches based on name.
105
+
106
+ ```
107
+ --branch '(-stable$|^master$)' # returns all potentially stable branches
108
+ ```
109
+
110
+ * **Type**: Regex String
111
+ * **Required?**: No
112
+ * **Default**: None
113
+
114
+ #### `--script` (or `-s`)
115
+
116
+ An path to a script to be executed on each derived branch across all derived repositories. This path can be absolute or relative to the directory in which the `wagemage` command is run.
117
+
118
+ ```
119
+ --script ~/wagemage_scripts/hunt_the_wumpus
120
+ --script /path/to/wagemage_scripts/angband
121
+ --script ./wagemage_scripts/arena_of_octos
122
+ --script scripts/dwarf_fortress
123
+ ```
124
+
125
+ * **Type**: Path String
126
+ * **Required?**: Yes
127
+ * **Default**: None
128
+
129
+ #### `--first-branch`
130
+
131
+ A boolean option to indicate that only the first branch in the derived list of branches for a repository should be operated upon.
132
+
133
+ ```
134
+ --branch '(-stable$|^master$)' \ # potentially returns `v2.1-stable, master`
135
+ --first-branch # operates on `v2.1-stable` only
136
+ ```
137
+
138
+ * **Type**: Boolean
139
+ * **Required?**: No
140
+ * **Default**: None
141
+
142
+ #### `--reviewers`
143
+
144
+ A comma-delineated list of GitHub users to add to the issued pull request. This list must not contain spaces.
145
+
146
+ ```
147
+ --reviewers bencrouse,mttdffy,tubbo,jyucis,meowsus
148
+ ```
149
+
150
+ * **Type**: Array
151
+ * **Required?**: Yes
152
+ * **Default**: None
153
+
154
+ #### `--branch-prefix`
155
+
156
+ The prefix of the "temporary" branch that is created before changes are made to the repository.
157
+
158
+ ```
159
+ --branch-prefix WORKAREA-123
160
+ ```
161
+
162
+ * **Type**: String
163
+ * **Required?**: Yes
164
+ * **Default**: `wagemage`
165
+
166
+ #### `--help` (or `-h`)
167
+
168
+ Displays the command's help and exits
169
+
170
+ #### `--version` (or `-v`)
171
+
172
+ Displays the command's version and exits
173
+
174
+ #### `--debug`
175
+
176
+ Prevents
177
+ * pushing branches to GitHub
178
+ * issuing pull requests
179
+ * temporary directory cleanup
180
+
181
+ ### Examples
182
+
183
+ All master branches across all repositories in a given organization:
184
+
185
+ ```sh
186
+ wagemage \
187
+ --org workarea-commerce \
188
+ --branch '^master$' \
189
+ --script ~/path/to/some/script.sh
190
+ ```
191
+
192
+ All master and development branches for a specific repository, and debug:
193
+
194
+ ```sh
195
+ wagemage \
196
+ --repo 'meowsus/wagemage' \
197
+ --branch '^(master|develop)$' \
198
+ --script relative/to/current/directory/script.sh \
199
+ --debug
200
+ ```
201
+
202
+ All stable release branches across the universe of Workarea and its plugins, prefixed with a Jira issue key to enable the Jira/GitHub integration, with all team members added to the pull request:
203
+
204
+ ```sh
205
+ wagemage \
206
+ --org workarea-commerce \
207
+ --repo '^workarea-commerce/workarea' \
208
+ --branch '(-stable$|^master$)' \
209
+ --script ./hunt_the_wumpus \
210
+ --branch-prefix WORKAREA-123 \
211
+ --reviewers bencrouse,mttdffy,tubbo,jyucis
212
+ ```
213
+
214
+ ## Scripting
215
+
216
+ As mentioned, the script is supplied with the current repository's path as the first argument, the current repository's name as the second, and the current branch name as the third.
217
+
218
+ The script can be of any type that is executable by the host machine.
219
+
220
+ The script **must** exit with a zero exit code to be considered successful. Exiting with a non-zero exit code tells Wagemage to skip operation on the current branch in the current repository.
221
+
222
+ Peruse [the examples](./examples) for a better understanding of what to do and contribute your own if you've done something noteworthy!
223
+
224
+ Any data sent to `STDERR` will be printed to your terminal after the command runs.
225
+
226
+ ## Development
227
+
228
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
229
+
230
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
231
+
232
+ ## Contributing
233
+
234
+ Bug reports and pull requests are welcome on GitHub at https://github.com/meowsus/wagemage. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
235
+
236
+ ## License
237
+
238
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
239
+
240
+ ## Code of Conduct
241
+
242
+ Everyone interacting in the Wagemage project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/meowsus/wagemage/blob/master/CODE_OF_CONDUCT.md).