heal 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +113 -15
- data/build.sh +1 -1
- data/lib/heal/cli/git.rb +54 -56
- data/lib/heal/cli/main.rb +50 -0
- data/lib/heal/cli/templates/config.yml +3 -1
- data/lib/heal/cli.rb +1 -1
- data/lib/heal/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: 7df98db2bf9734c0746ba355d93805baf195a517874f338b23dcc41043f3a55f
|
4
|
+
data.tar.gz: 8c3d7e97f5b79ce75b0ee3176a55cb2afa0b6e465838c0663afadffd1cc9b329
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d08e1649677f4ec313d2a41a93e62a6d373d7a1d8f59822291e2cf971ab9f5dd5ad46fb02437324805a7d79e20abd1a0e08a62f6b5db95c3899be75577e632d1
|
7
|
+
data.tar.gz: 5519454a9cbb3ef4f9fc2dee54380de79ccd999055a3a43493d437faa4a524653d761b566800302777fc02c569222472b8b42b8eb1c85933ed5fb72d3b491bec
|
data/README.md
CHANGED
@@ -1,34 +1,132 @@
|
|
1
1
|
# Heal
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/heal`. To experiment with that code, run `bin/console` for an interactive prompt.
|
3
|
+
Heal is a command-line interface for managing Git workflows and configurations.
|
6
4
|
|
7
5
|
## Installation
|
8
6
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
7
|
+
To install the Heal CLI, follow these steps:
|
8
|
+
|
9
|
+
1. **Add the gem to your Gemfile**:
|
10
|
+
```ruby
|
11
|
+
gem 'heal'
|
12
|
+
```
|
13
|
+
|
14
|
+
2. **Install the gem**:
|
15
|
+
Run the following command in your terminal:
|
16
|
+
```bash
|
17
|
+
bundle install
|
18
|
+
```
|
19
|
+
|
20
|
+
If you are not using Bundler, you can install the gem directly:
|
21
|
+
```bash
|
22
|
+
gem install heal
|
23
|
+
```
|
24
|
+
|
25
|
+
3. **Verify the installation**:
|
26
|
+
After installation, you can verify that the Heal CLI is working by running:
|
27
|
+
```bash
|
28
|
+
heal help
|
29
|
+
```
|
30
|
+
|
31
|
+
## Available Commands
|
32
|
+
|
33
|
+
### Configuration
|
34
|
+
|
35
|
+
- **`config`**:
|
36
|
+
- **Description**: Displays the current configuration settings.
|
37
|
+
- **Usage**:
|
38
|
+
```bash
|
39
|
+
heal config
|
40
|
+
```
|
41
|
+
|
42
|
+
### Commands
|
43
|
+
|
44
|
+
- **`delivery`**:
|
45
|
+
- **Description**: Delivers an issue to the test environment by checking out the relevant branches and cherry-picking commits associated with the specified issue ID.
|
46
|
+
- **Usage**:
|
47
|
+
```bash
|
48
|
+
heal delivery
|
49
|
+
```
|
50
|
+
|
51
|
+
- **`release`**:
|
52
|
+
- **Description**: Releases a feature to a production-ready branch by cherry-picking commits from issues under an EPIC.
|
53
|
+
- **Usage**:
|
54
|
+
```bash
|
55
|
+
heal release
|
56
|
+
```
|
57
|
+
|
58
|
+
- **`git cherry-pick-pr COMMIT_MESSAGE_IDENTIFIER REPO SOURCE_BRANCH TARGET_BRANCH THROWAWAY_BRANCH`**:
|
59
|
+
- **Description**: Cherry picks a PR based on a commit message identifier (like a JIRA key), source repository, source branch, target branch, and a throwaway branch used for creating a PR to the target branch.
|
60
|
+
- **Usage**:
|
61
|
+
```bash
|
62
|
+
heal git cherry-pick-pr <COMMIT_MESSAGE_IDENTIFIER> <REPO> <SOURCE_BRANCH> <TARGET_BRANCH> <THROWAWAY_BRANCH>
|
63
|
+
```
|
64
|
+
|
65
|
+
- **`git find-commits COMMIT_MESSAGE_IDENTIFIER`**:
|
66
|
+
- **Description**: Finds commit IDs based on an identifier in the commit message.
|
67
|
+
- **Usage**:
|
68
|
+
```bash
|
69
|
+
heal git find-commits <COMMIT_MESSAGE_IDENTIFIER>
|
70
|
+
```
|
71
|
+
|
72
|
+
- **`git create-pr REPO_NAME SOURCE_BRANCH TO_BRANCH`**:
|
73
|
+
- **Description**: Creates a PR from a source branch to a target branch in the specified repository.
|
74
|
+
- **Usage**:
|
75
|
+
```bash
|
76
|
+
heal git create-pr <REPO_NAME> <SOURCE_BRANCH> <TO_BRANCH>
|
77
|
+
```
|
78
|
+
|
79
|
+
## Configuration File
|
80
|
+
|
81
|
+
The Heal CLI uses a configuration file to manage settings. By default, the configuration file is located at `~/.heal/config.yml`. You can specify a different path using the `-c` option.
|
82
|
+
|
83
|
+
### Configuration Structure
|
84
|
+
|
85
|
+
The configuration file should include the following sections:
|
86
|
+
|
87
|
+
- **git**: Contains Git-related settings.
|
88
|
+
- **repos**: An array of repository paths that the CLI will manage.
|
89
|
+
- **directories**: An array of directories to search for Git repositories.
|
90
|
+
- **branch**: Contains branch settings.
|
91
|
+
- **prefix**: The prefix for branch names.
|
92
|
+
- **targets**: Specifies target branches for delivery and development.
|
93
|
+
|
94
|
+
### Example Configuration
|
95
|
+
|
96
|
+
```yaml
|
97
|
+
git:
|
98
|
+
repos:
|
99
|
+
- /path/to/repo1
|
100
|
+
- /path/to/repo2
|
101
|
+
directories:
|
102
|
+
- ~/projects
|
103
|
+
branch:
|
104
|
+
prefix: "feature"
|
105
|
+
targets:
|
106
|
+
test: "test-branch"
|
107
|
+
development: "dev-branch"
|
108
|
+
release: "release-branch"
|
109
|
+
```
|
14
110
|
|
15
|
-
|
111
|
+
## Usage
|
16
112
|
|
17
|
-
|
113
|
+
To use the Heal CLI, simply run the command followed by the desired subcommand. For example:
|
18
114
|
|
19
|
-
|
115
|
+
```bash
|
116
|
+
heal delivery
|
117
|
+
```
|
20
118
|
|
21
|
-
|
119
|
+
This command will initiate the delivery process for the issue with the ID prompted by the user.
|
22
120
|
|
23
121
|
## Development
|
24
122
|
|
25
123
|
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.
|
26
124
|
|
27
|
-
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 the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
125
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `lib/heal/version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
28
126
|
|
29
127
|
## Contributing
|
30
128
|
|
31
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
129
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/jjatinggoyal/heal. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/jjatinggoyal/heal/blob/master/CODE_OF_CONDUCT.md).
|
32
130
|
|
33
131
|
## License
|
34
132
|
|
@@ -36,4 +134,4 @@ The gem is available as open source under the terms of the [MIT License](https:/
|
|
36
134
|
|
37
135
|
## Code of Conduct
|
38
136
|
|
39
|
-
Everyone interacting in the Heal project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/
|
137
|
+
Everyone interacting in the Heal project's codebases, issue trackers, chat rooms, and mailing lists is expected to follow the [code of conduct](https://github.com/jjatinggoyal/heal/blob/master/CODE_OF_CONDUCT.md).
|
data/build.sh
CHANGED
@@ -1,2 +1,2 @@
|
|
1
1
|
gem build heal.gemspec
|
2
|
-
gem install heal-0.0.
|
2
|
+
gem install heal-0.0.2.gem
|
data/lib/heal/cli/git.rb
CHANGED
@@ -1,45 +1,38 @@
|
|
1
1
|
class Heal::Cli::Git < Heal::Cli::Base
|
2
2
|
|
3
|
-
desc "
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
end
|
3
|
+
desc "cherry-pick-pr COMMIT_MESSAGE_IDENTIFIER REPO SOURCE_BRANCH TARGET_BRANCH THROWAWAY_BRANCH",
|
4
|
+
"Cherry Pick a PR based on a commit message identifier (like jira key), source repository, source branch, target branch and a throwaway branch used for creating PR to target branch"
|
5
|
+
def cherry_pick_pr(commit_message_identifier, repo, source_branch, target_branch, throwaway_branch)
|
6
|
+
prepare repo do
|
7
|
+
checkout_and_pull source_branch
|
8
|
+
commits = invoke "heal:cli:git:find-commits", [commit_message_identifier]
|
9
|
+
checkout_and_pull target_branch
|
10
|
+
checkout_new_branch throwaway_branch
|
11
|
+
|
12
|
+
cherry_pick_commits(commits)
|
13
|
+
|
14
|
+
git :push, :origin, throwaway_branch
|
15
|
+
invoke "heal:cli:git:create-pr", [repo_name, throwaway_branch, target_branch]
|
17
16
|
end
|
18
17
|
end
|
19
18
|
|
20
|
-
desc "
|
21
|
-
def
|
22
|
-
|
19
|
+
desc "find-commits COMMIT_MESSAGE_IDENTIFIER", "Find commit ids based on an identifier in commit message"
|
20
|
+
def find_commits(commit_message_identifier)
|
21
|
+
p `#{git :log, :"--oneline", :"--grep", commit_message_identifier, execute: false}`.lines.map { |line| line.split.first }.reverse
|
23
22
|
end
|
24
23
|
|
25
|
-
private
|
26
|
-
|
27
|
-
def ask_repo_choices
|
28
|
-
choices = @config["git"]["repos"].map { |repo| { File.basename(repo) => repo } }
|
29
|
-
PROMPT.multi_select("Choose repositories:", choices, filter: true)
|
30
|
-
end
|
31
|
-
|
32
|
-
def delivery_branch
|
33
|
-
@config["git"]["branch"]["targets"]["test"]
|
34
|
-
end
|
35
24
|
|
36
|
-
|
37
|
-
|
25
|
+
# Opens a link to create a PR from +source_branch+ to +target_branch+ in +repo_name+
|
26
|
+
#
|
27
|
+
# @param repository_name [String] name of the repository to create the PR in
|
28
|
+
# @param source_branch [String] name of the branch to create the PR from
|
29
|
+
# @param target_branch [String] name of the branch to create the PR to
|
30
|
+
desc "create-pr REPO_NAME SOURCE_BRANCH TO_BRANCH", "Create a PR from a source to a target branch"
|
31
|
+
def create_pr(repository_name, source_branch, target_branch)
|
32
|
+
`open #{format(@config["git"]["pr_link"], repository_name, source_branch, target_branch)}`
|
38
33
|
end
|
39
34
|
|
40
|
-
|
41
|
-
@config["git"]["branch"]["prefix"] + "/" + delivery_branch + "/" + issue_id
|
42
|
-
end
|
35
|
+
private
|
43
36
|
|
44
37
|
def prepare(repo_path)
|
45
38
|
@path = repo_path
|
@@ -60,6 +53,35 @@ class Heal::Cli::Git < Heal::Cli::Base
|
|
60
53
|
`#{git :log, :"--oneline", :"--grep", issue_id, execute: false}`.lines.map { |line| line.split.first }
|
61
54
|
end
|
62
55
|
|
56
|
+
def checkout_new_branch(throwaway_branch)
|
57
|
+
branch_already_present = (git :"rev-parse", :"--verify", throwaway_branch) || (git :"rev-parse", :"--verify", "origin/#{throwaway_branch}")
|
58
|
+
if branch_already_present
|
59
|
+
git :checkout, throwaway_branch
|
60
|
+
else
|
61
|
+
git :checkout, :"-b", throwaway_branch
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
def cherry_pick_commits(commits)
|
66
|
+
commits.each do |commit|
|
67
|
+
result = git :"cherry-pick", :"-x", :"--no-merges", commit
|
68
|
+
unless result
|
69
|
+
say "Conflict occurred while cherry-picking commit #{commit}. Please resolve the conflict and press any key to continue.", :red
|
70
|
+
|
71
|
+
loop do
|
72
|
+
# Check if there are unresolved conflicts
|
73
|
+
if `#{git :status, execute: false}`.include?("Unmerged paths")
|
74
|
+
PROMPT.keypress("Please resolve the conflicts and then press any key to continue...", active_color: :red)
|
75
|
+
else
|
76
|
+
say "Conflict resolved. Continuing with cherry-picking.", :green
|
77
|
+
git :"cherry-pick", :"--continue"
|
78
|
+
break # Exit the loop if conflicts are resolved
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
63
85
|
def current_branch
|
64
86
|
`#{git :"rev-parse", :"--abbrev-ref", :HEAD, execute: false}`.strip
|
65
87
|
end
|
@@ -74,10 +96,6 @@ class Heal::Cli::Git < Heal::Cli::Base
|
|
74
96
|
false
|
75
97
|
end
|
76
98
|
|
77
|
-
def create_pr(from:, to:)
|
78
|
-
`open #{format(@config["git"]["pr_link"], repo_name, from, to)}`
|
79
|
-
end
|
80
|
-
|
81
99
|
def repo_name
|
82
100
|
`#{git :remote, :"get-url", :origin, execute: false}`.match(/.*\/(.*?)\.git/)[1]
|
83
101
|
end
|
@@ -87,24 +105,4 @@ class Heal::Cli::Git < Heal::Cli::Base
|
|
87
105
|
execute ? system(command) : command
|
88
106
|
end
|
89
107
|
|
90
|
-
def cherry_pick_commits(commits)
|
91
|
-
commits.each do |commit|
|
92
|
-
result = git :"cherry-pick", :"-x", :"--no-merges", commit
|
93
|
-
unless result
|
94
|
-
say "Conflict occurred while cherry-picking commit #{commit}. Please resolve the conflict and press any key to continue.", :red
|
95
|
-
|
96
|
-
loop do
|
97
|
-
# Check if there are unresolved conflicts
|
98
|
-
if `#{git :status, execute: false}`.include?("Unmerged paths")
|
99
|
-
PROMPT.keypress("Please resolve the conflicts and then press any key to continue...", active_color: :red)
|
100
|
-
else
|
101
|
-
say "Conflict resolved. Continuing with cherry-picking.", :green
|
102
|
-
git :"cherry-pick", :"--continue"
|
103
|
-
break # Exit the loop if conflicts are resolved
|
104
|
-
end
|
105
|
-
end
|
106
|
-
end
|
107
|
-
end
|
108
|
-
end
|
109
|
-
|
110
108
|
end
|
data/lib/heal/cli/main.rb
CHANGED
@@ -5,7 +5,57 @@ class Heal::Cli::Main < Heal::Cli::Base
|
|
5
5
|
puts @config.to_yaml
|
6
6
|
end
|
7
7
|
|
8
|
+
desc "delivery", "Deliver an issue to test environment"
|
9
|
+
def delivery
|
10
|
+
issue_id = PROMPT.ask("Please enter the Issue key...\n", required: true)
|
11
|
+
|
12
|
+
source_branch = development_branch(issue_id)
|
13
|
+
|
14
|
+
ask_repo_choices.each do |repo|
|
15
|
+
invoke "heal:cli:git:cherry-pick-pr", [issue_id, repo, source_branch, delivery_branch, issue_branch(issue_id)]
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
desc "release", "Release a Feature to a production ready branch"
|
20
|
+
def release
|
21
|
+
feature_id = PROMPT.ask("Enter the Feature key...\n", required: true)
|
22
|
+
feature_issues = PROMPT.ask("Enter all issues under the EPIC: JIRA-1,JIRA-2,...\n", required: true, convert: :array)
|
23
|
+
|
24
|
+
ask_repo_choices.each do |repo|
|
25
|
+
feature_issues.each do |issue_id|
|
26
|
+
invoke "heal:cli:git:cherry-pick-pr", [issue_id, repo, issue_branch(issue_id), release_branch, feature_branch(feature_id)]
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
8
31
|
desc "git", "Manage Git workflows"
|
9
32
|
subcommand "git", Heal::Cli::Git
|
10
33
|
|
34
|
+
private
|
35
|
+
|
36
|
+
def ask_repo_choices
|
37
|
+
choices = @config["git"]["repos"].map { |repo| { File.basename(repo) => repo } }
|
38
|
+
PROMPT.multi_select("Choose repositories:", choices, filter: true)
|
39
|
+
end
|
40
|
+
|
41
|
+
def development_branch(issue_id)
|
42
|
+
@config["git"]["branch"]["prefix"]["test"] + "/" + @config["git"]["branch"]["targets"]["development"] + "/" + issue_id
|
43
|
+
end
|
44
|
+
|
45
|
+
def delivery_branch
|
46
|
+
@config["git"]["branch"]["targets"]["test"]
|
47
|
+
end
|
48
|
+
|
49
|
+
def release_branch
|
50
|
+
@config["git"]["branch"]["targets"]["release"]
|
51
|
+
end
|
52
|
+
|
53
|
+
def issue_branch(issue_id)
|
54
|
+
@config["git"]["branch"]["prefix"]["test"] + "/" + delivery_branch + "/" + issue_id
|
55
|
+
end
|
56
|
+
|
57
|
+
def feature_branch(feature_id)
|
58
|
+
@config["git"]["branch"]["prefix"]["release"] + "/" + feature_id
|
59
|
+
end
|
60
|
+
|
11
61
|
end
|
data/lib/heal/cli.rb
CHANGED
data/lib/heal/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: heal
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jatin Goyal
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-11-
|
11
|
+
date: 2024-11-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|