git_helper 1.0.1 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: aa43ec8474f02e1d7b042c0706870e9b2e148f4c17749615808c7111ffd1657a
4
- data.tar.gz: 4b3a1b77bf3c4c8086077a768e9cdcba41683ea5daf3bcfe39b330ac9a9d142e
3
+ metadata.gz: d8f1759701099c875fd08dd2b4fe00f55732c7d005a3437a5adea5019bbcf78b
4
+ data.tar.gz: e659e2c1bc529059854e9d35daa3d8afea6f9e13877d6cd1681b621a299995f0
5
5
  SHA512:
6
- metadata.gz: 7282a13816db9c1eb5653ca77b9d18c251332a9c19dc30e546d2cf074796c0e4b14e6954b1994c54de30d7f6931413d164e3f6666164e8ca5a6a3db2cfe97b46
7
- data.tar.gz: be5d4519977cc3205aed2776809e0a062b554102b41eb0db92dc4082aaec6a404e5d3317c0482e05c448c199c6e6a28bf1745f8c9f63faec963d833b4ea8f59f
6
+ metadata.gz: 01f01fcf9cb8e962a07488e76ae04f2ac0b0e612c089b7479da39f26598adccd8c005fa85d38bd430a5642fc8d1760e4738d3ef76759c77eb7cbce1926ff34d3
7
+ data.tar.gz: 9e7b63ec6d2ed7b62ca689c1cfd33eeb5830becdfef13fffe06f068a9181834393e5f4ff3f1885df2f63b12a1a90f4f22024d4d72a3d88ea4c0c7191a8fa90a8
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # git_helper [![Maintainability](https://api.codeclimate.com/v1/badges/d53da11f17c38cc81b5b/maintainability)](https://codeclimate.com/github/emmasax4/git_helper/maintainability) ![Develop](https://github.com/emmasax4/git_helper/workflows/Develop/badge.svg)
2
2
 
3
- ## Usage
3
+ ## Gem Usage
4
4
 
5
5
  ```bash
6
6
  gem install git_helper
@@ -17,14 +17,54 @@ Some of the commands in this gem can be used without any additional configuratio
17
17
 
18
18
  To view the help screen, run:
19
19
  ```bash
20
- ghelper --help
20
+ git-helper --help
21
21
  ```
22
22
 
23
23
  To see what version of git_helper you're running, run:
24
24
  ```bash
25
- ghelper --version
25
+ git-helper --version
26
26
  ```
27
27
 
28
+ ## Plugin Usage
29
+
30
+ As an additional option, you can set each of the following commands to be a git plugin, meaning you can call them in a way that feels even more git-native:
31
+
32
+ ```bash
33
+ # As a Gem # As a Plugin
34
+ git-helper clean-branches git clean-branches
35
+ git-helper pull-request --create git pull-request --create
36
+ ```
37
+
38
+ To do this, clone this repository from GitHub, and add the following line to your `~/.bash_profile`:
39
+
40
+ ```
41
+ export PATH=/your/path/to/this/repository/git_helper/plugins:$PATH
42
+ ```
43
+
44
+ And then run `source ~/.bash_profile`.
45
+
46
+ ## Alias Usage
47
+
48
+ To make the commands even shorter, I recommend setting aliases. You can either set aliases through git itself, like this (only possible if you also use the plugin option):
49
+
50
+ ```bash
51
+ git config --global alias.nb new-branch
52
+ ```
53
+
54
+ And then running `git nb` maps to `git new-branch`, which through the plugin, maps to `git-helper new-branch`.
55
+
56
+ Or you can set the alias through your `~/.bashrc` (which is my preferred method because it can make the command even shorter, and doesn't require the plugin usage). To do this, add lines like this to the `~/.bashrc` file and run `source ~/.bashrc`:
57
+
58
+ ```bash
59
+ alias gnb="git new-branch"
60
+ ```
61
+
62
+ And then, running `gnb` maps to `git new-branch`, which again routes to `git-helper new-branch`.
63
+
64
+ For a full list of the git aliases I prefer to use, check out my [Git Aliases gist](https://gist.github.com/emmasax4/e8744fe253fba1f00a621c01a2bf68f5).
65
+
66
+ If you're going to make using git workflows easier, might as well provide lots of options 😃.
67
+
28
68
  ## Commands
29
69
 
30
70
  ### `change-remote`
@@ -34,7 +74,7 @@ This can be used when switching the owners of a GitHub repo. When you switch a u
34
74
  This command will go through every directory in a directory, see if it is a git directory, and then will check to see if the old username is included in the remote URL of that git directory. If it is, then the command will change the remote URL to instead point to the new username's remote URL. To run the command, run:
35
75
 
36
76
  ```bash
37
- ghelper change-remote OLD-OWNER NEW-OWNER
77
+ git-helper change-remote OLD-OWNER NEW-OWNER
38
78
  ```
39
79
 
40
80
  ### `checkout-default`
@@ -42,7 +82,7 @@ ghelper change-remote OLD-OWNER NEW-OWNER
42
82
  This command will check out the default branch of whatever repository you're currently in. It looks at what branch the `origin/HEAD` remote is pointed to on your local machine, versus querying GitHub/GitLab for that, so if your local machine's remotes aren't up to date, then this command won't work as expected. To run this command, run:
43
83
 
44
84
  ```bash
45
- ghelper checkout-default
85
+ git-helper checkout-default
46
86
  ```
47
87
 
48
88
  If your local branches aren't right (run `git branch --remote` to see), then run:
@@ -51,12 +91,12 @@ If your local branches aren't right (run `git branch --remote` to see), then run
51
91
  git symbolic-ref refs/remotes/origin/HEAD refs/remotes/origin/CORRECT-DEFAULT-BRANCH-GOES-HERE
52
92
  ```
53
93
 
54
- ### `clean-git`
94
+ ### `clean-branches`
55
95
 
56
96
  This command will bring you to the repository's default branch, `git pull`, `git fetch -p`, and will clean up your local branches on your machine by seeing which ones are existing on the remote, and updating yours accordingly. To run:
57
97
 
58
98
  ```bash
59
- ghelper clean-git
99
+ git-helper clean-branches
60
100
  ```
61
101
 
62
102
  ### `empty-commit`
@@ -64,54 +104,54 @@ ghelper clean-git
64
104
  For some reason, I'm always forgetting the commands to create an empty commit. So with this command, it becomes easy. The commit message of this commit will be `'Empty commit'`. To run the command, run:
65
105
 
66
106
  ```bash
67
- ghelper empty-commit
107
+ git-helper empty-commit
68
108
  ```
69
109
 
70
- ### `new-branch`
110
+ ### `merge-request`
71
111
 
72
- This command is useful for making new branches in a repository on the command line. To run the command, run:
112
+ This command can be used to handily make new GitLab merge requests and to accept merge requests from the command line. The command uses the Ruby wrapper [`Gitlab`](https://github.com/NARKOZ/gitlab) to do this, so make sure you have a `.git_config.yml` file set up in the home directory of your computer. For instructions on how to do that, see [Usage](#usage).
113
+
114
+ After setup is complete, you can call the file, and send in a flag indicating whether to create a pull request, `-c`, or to merge a pull request, `-m`.
73
115
 
74
116
  ```bash
75
- ghelper new-branch
117
+ git-helper merge-request -c
76
118
  # OR
77
- ghelper new-branch NEW_BRANCH_NAME
119
+ git-helper merge-request -m
78
120
  ```
79
121
 
80
- The command either accepts a branch name right away or it will ask you for the name of your new branch. Make sure your input does not contain any spaces or special characters.
122
+ If you're trying to create a merge request, the command will provide an autogenerated merge request title based on your branch name (separated by `_`). You can respond 'yes' or 'no'. If you respond 'no', you can provide your own merge request title. The command will also ask you if the default branch of the repository is the proper base branch to use. You can say 'yes' or 'no'. If you respond 'no', then you can give the command your chosen base base. Lastly, it'll ask the user to apply any merge request templates found at any `*/merge_request_template.md` file or any file in `.gitlab/merge_request_templates/*.md`. Applying any template is optional, and from the command's standpoint, a user can make an empty merge request if they desire. If a GitLab project automatically adds a template, then it may create a merge request with a default template anyway.
81
123
 
82
- ### `pull-request`
124
+ If you're requesting to merge a merge request, the command will ask you the number ID of the merge request you wish to accept. The command will also ask you what type of merge to do: regular merging or squashing. The commit message to use during the merge/squash will be the title of the pull request.
83
125
 
84
- This command can be used to handily make new GitHub pull requests and to merge pull requests from the command line. The command uses the [`Octokit::Client`](https://octokit.github.io/octokit.rb/Octokit/Client.html) to do this, so make sure you have a `.git_config.yml` file set up in the home directory of your computer. For instructions on how to do that, see [Usage](#usage).
126
+ If you're getting stuck, you can run the command with a `--help` flag instead, to get some more information.
85
127
 
86
- After setup is complete, you can call the file, and send in a flag indicating whether to create a pull request, `-c`, or to merge a pull request, `-m`.
128
+ ### `new-branch`
129
+
130
+ This command is useful for making new branches in a repository on the command line. To run the command, run:
87
131
 
88
132
  ```bash
89
- ghelper pull-request -c
133
+ git-helper new-branch
90
134
  # OR
91
- ghelper pull-request -m
135
+ git-helper new-branch NEW_BRANCH_NAME
92
136
  ```
93
137
 
94
- If you're trying to create a pull request, the command will provide an autogenerated pull request title based on your branch name (separated by `_`). You can respond 'yes' or 'no'. If you respond 'no', you can provide your own pull request title. The command will also ask you if the default branch of the repository is the proper base branch to use. You can say 'yes' or 'no'. If you respond 'no', then you can give the command your chosen base base. Lastly, it'll ask the user to apply any pull request templates found at any `*/pull_request_template.md` file or any file in `.github/PULL_REQUEST_TEMPLATE/*.md`. Applying any template is optional, and a user can make an empty pull request if they desire.
95
-
96
- If you're requesting to merge a pull request, the command will ask you the number ID of the pull request you wish to merge. The command will also ask you what type of merge to do: regular merging, squashing, or rebasing. The commit message to use during the merge/squash/rebase will be the title of the pull request.
97
-
98
- If you're getting stuck, you can run the command with a `--help` flag instead, to get some more information.
138
+ The command either accepts a branch name right away or it will ask you for the name of your new branch. Make sure your input does not contain any spaces or special characters.
99
139
 
100
- ### `merge-request`
140
+ ### `pull-request`
101
141
 
102
- This command can be used to handily make new GitLab merge requests and to accept merge requests from the command line. The command uses the Ruby wrapper [`Gitlab`](https://github.com/NARKOZ/gitlab) to do this, so make sure you have a `.git_config.yml` file set up in the home directory of your computer. For instructions on how to do that, see [Usage](#usage).
142
+ This command can be used to handily make new GitHub pull requests and to merge pull requests from the command line. The command uses the [`Octokit::Client`](https://octokit.github.io/octokit.rb/Octokit/Client.html) to do this, so make sure you have a `.git_config.yml` file set up in the home directory of your computer. For instructions on how to do that, see [Usage](#usage).
103
143
 
104
144
  After setup is complete, you can call the file, and send in a flag indicating whether to create a pull request, `-c`, or to merge a pull request, `-m`.
105
145
 
106
146
  ```bash
107
- ghelper merge-request -c
147
+ git-helper pull-request -c
108
148
  # OR
109
- ghelper merge-request -m
149
+ git-helper pull-request -m
110
150
  ```
111
151
 
112
- If you're trying to create a merge request, the command will provide an autogenerated merge request title based on your branch name (separated by `_`). You can respond 'yes' or 'no'. If you respond 'no', you can provide your own merge request title. The command will also ask you if the default branch of the repository is the proper base branch to use. You can say 'yes' or 'no'. If you respond 'no', then you can give the command your chosen base base. Lastly, it'll ask the user to apply any merge request templates found at any `*/merge_request_template.md` file or any file in `.gitlab/merge_request_templates/*.md`. Applying any template is optional, and from the command's standpoint, a user can make an empty merge request if they desire. If a GitLab project automatically adds a template, then it may create a merge request with a default template anyway.
152
+ If you're trying to create a pull request, the command will provide an autogenerated pull request title based on your branch name (separated by `_`). You can respond 'yes' or 'no'. If you respond 'no', you can provide your own pull request title. The command will also ask you if the default branch of the repository is the proper base branch to use. You can say 'yes' or 'no'. If you respond 'no', then you can give the command your chosen base base. Lastly, it'll ask the user to apply any pull request templates found at any `*/pull_request_template.md` file or any file in `.github/PULL_REQUEST_TEMPLATE/*.md`. Applying any template is optional, and a user can make an empty pull request if they desire.
113
153
 
114
- If you're requesting to merge a merge request, the command will ask you the number ID of the merge request you wish to accept. The command will also ask you what type of merge to do: regular merging or squashing. The commit message to use during the merge/squash will be the title of the pull request.
154
+ If you're requesting to merge a pull request, the command will ask you the number ID of the pull request you wish to merge. The command will also ask you what type of merge to do: regular merging, squashing, or rebasing. The commit message to use during the merge/squash/rebase will be the title of the pull request.
115
155
 
116
156
  If you're getting stuck, you can run the command with a `--help` flag instead, to get some more information.
117
157
 
@@ -28,7 +28,7 @@ command 'change-remote' do |c|
28
28
  end
29
29
  end
30
30
 
31
- desc "Checks out the default branch of the repository based on the repository's local remote branches."
31
+ desc "Checks out the default branch of a repo based on the local remote branches."
32
32
  command 'checkout-default' do |c|
33
33
  c.action do |global_options, options, args|
34
34
  require_relative '../lib/git_helper/checkout_default.rb'
@@ -37,10 +37,10 @@ command 'checkout-default' do |c|
37
37
  end
38
38
 
39
39
  desc "Clean a repository's git branches."
40
- command 'clean-git' do |c|
40
+ command 'clean-branches' do |c|
41
41
  c.action do |global_options, options, args|
42
- require_relative '../lib/git_helper/clean_git.rb'
43
- GitHelper::CleanGit.new.execute
42
+ require_relative '../lib/git_helper/clean_branches.rb'
43
+ GitHelper::CleanBranches.new.execute
44
44
  end
45
45
  end
46
46
 
@@ -59,7 +59,7 @@ command 'merge-request' do |c|
59
59
 
60
60
  c.action do |global_options, options, args|
61
61
  require_relative '../lib/git_helper/merge_request.rb'
62
- raise ArgumentError, 'You must specify an action (either --merge or --create)' unless options[:create] || options[:merge]
62
+ raise ArgumentError, "You must specify an action (either '-m'/'--merge' or '-c'/'--create')" unless options[:create] || options[:merge]
63
63
 
64
64
  options = global_options.merge(options)
65
65
 
@@ -87,7 +87,7 @@ command 'pull-request' do |c|
87
87
 
88
88
  c.action do |global_options, options, args|
89
89
  require_relative '../lib/git_helper/pull_request.rb'
90
- raise ArgumentError, 'You must specify an action (either --merge or --create)' unless options[:create] || options[:merge]
90
+ raise ArgumentError, "You must specify an action (either '-m'/'--merge' or '-c'/'--create')" unless options[:create] || options[:merge]
91
91
 
92
92
  options = global_options.merge(options)
93
93
 
@@ -1,5 +1,5 @@
1
1
  module GitHelper
2
- class CleanGit
2
+ class CleanBranches
3
3
  def execute
4
4
  system("git checkout $(git symbolic-ref refs/remotes/origin/HEAD | sed \"s@^refs/remotes/origin/@@\")")
5
5
  system("git pull")
@@ -1,3 +1,3 @@
1
1
  module GitHelper
2
- VERSION = '1.0.1'
2
+ VERSION = '1.1.0'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: git_helper
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Emma Sax
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-09-09 00:00:00.000000000 Z
11
+ date: 2020-09-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: gitlab
@@ -140,7 +140,7 @@ description: A set of GitHub and GitLab workflow scripts.
140
140
  email:
141
141
  - emma.sax4@gmail.com
142
142
  executables:
143
- - ghelper
143
+ - git-helper
144
144
  extensions: []
145
145
  extra_rdoc_files: []
146
146
  files:
@@ -150,11 +150,11 @@ files:
150
150
  - LICENSE
151
151
  - README.md
152
152
  - Rakefile
153
- - bin/ghelper
153
+ - bin/git-helper
154
154
  - lib/git_helper.rb
155
155
  - lib/git_helper/change_remote.rb
156
156
  - lib/git_helper/checkout_default.rb
157
- - lib/git_helper/clean_git.rb
157
+ - lib/git_helper/clean_branches.rb
158
158
  - lib/git_helper/empty_commit.rb
159
159
  - lib/git_helper/git_config_reader.rb
160
160
  - lib/git_helper/gitlab_client.rb