merge-commit-and-feature: commit moved commit script as feature subcommand
This commit is contained in:
33
README.md
33
README.md
@@ -4,7 +4,6 @@ This is a collection of simple command-line scripts, bash aliases, and bash util
|
|||||||
|
|
||||||
The command-line scripts include:
|
The command-line scripts include:
|
||||||
|
|
||||||
* commit - make using `git-commmit` easier
|
|
||||||
* feature - make working with feature branches easier
|
* feature - make working with feature branches easier
|
||||||
* xgrep - make using `git-grep` easier
|
* xgrep - make using `git-grep` easier
|
||||||
|
|
||||||
@@ -57,18 +56,6 @@ To include the `bash` aliases and enable tab completion for the `feature` script
|
|||||||
source ~/GitHub/rkiel/git-utilities/dotfiles/bashrc
|
source ~/GitHub/rkiel/git-utilities/dotfiles/bashrc
|
||||||
```
|
```
|
||||||
|
|
||||||
## Commit utility
|
|
||||||
|
|
||||||
This utility makes it easier to write commit messages.
|
|
||||||
No need to specify the `-m` parameter or wrapping the message in quotes.
|
|
||||||
For example,
|
|
||||||
|
|
||||||
```
|
|
||||||
commit this is a sample commit message
|
|
||||||
```
|
|
||||||
|
|
||||||
generates the command `git commit -m "this is a sample commit message"`.
|
|
||||||
|
|
||||||
## Feature utility
|
## Feature utility
|
||||||
|
|
||||||
### Usage
|
### Usage
|
||||||
@@ -123,6 +110,26 @@ You can also override the default standard branch by specifying another branch.
|
|||||||
feature merge integration
|
feature merge integration
|
||||||
```
|
```
|
||||||
|
|
||||||
|
#### Commit
|
||||||
|
|
||||||
|
Use the `commit` subcommand to make it easier to write commit messages.
|
||||||
|
No need to specify the `-m` parameter or wrapping the message in quotes.
|
||||||
|
If you forget and pass in `-m` anyway, it will ignore it.
|
||||||
|
For example,
|
||||||
|
|
||||||
|
```
|
||||||
|
feature commit this is a sample commit message
|
||||||
|
feature commit -m this is a sample commit message
|
||||||
|
```
|
||||||
|
|
||||||
|
generates the command `git commit -m "this is a sample commit message"`.
|
||||||
|
|
||||||
|
The commit message will be prepended with the feature name. For example,
|
||||||
|
|
||||||
|
```
|
||||||
|
my-feature-name: this is a sample commit message
|
||||||
|
```
|
||||||
|
|
||||||
#### End
|
#### End
|
||||||
|
|
||||||
Use the `end` subcommand to close out the feature.
|
Use the `end` subcommand to close out the feature.
|
||||||
|
|||||||
10
bin/commit
10
bin/commit
@@ -1,10 +0,0 @@
|
|||||||
#!/usr/bin/env ruby
|
|
||||||
|
|
||||||
require_relative '../lib/commit/commander'
|
|
||||||
|
|
||||||
commander = Commit::Commander.new(ARGV)
|
|
||||||
if commander.valid?
|
|
||||||
commander.execute
|
|
||||||
else
|
|
||||||
commander.help
|
|
||||||
end
|
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
alias add="git add"
|
alias add="git add"
|
||||||
alias branch="git branch"
|
alias branch="git branch"
|
||||||
alias checkout="git checkout"
|
alias checkout="git checkout"
|
||||||
|
alias commit="feature commit"
|
||||||
alias pop="git stash pop --index"
|
alias pop="git stash pop --index"
|
||||||
alias pull="git pull"
|
alias pull="git pull"
|
||||||
alias push="git push"
|
alias push="git push"
|
||||||
|
|||||||
@@ -1,39 +0,0 @@
|
|||||||
require_relative '../shared/branchability'
|
|
||||||
require_relative '../shared/runnable'
|
|
||||||
|
|
||||||
module Commit
|
|
||||||
|
|
||||||
class Commander
|
|
||||||
|
|
||||||
include Shared::Branchability
|
|
||||||
include Shared::Runnable
|
|
||||||
|
|
||||||
attr_reader :argv
|
|
||||||
|
|
||||||
def initialize (argv)
|
|
||||||
@argv = argv
|
|
||||||
end
|
|
||||||
|
|
||||||
def valid?
|
|
||||||
argv.size > 0
|
|
||||||
end
|
|
||||||
|
|
||||||
def help
|
|
||||||
puts
|
|
||||||
puts "USAGE: commit [word....]"
|
|
||||||
puts
|
|
||||||
exit
|
|
||||||
end
|
|
||||||
|
|
||||||
def execute
|
|
||||||
parts = parse_branch(current_branch)
|
|
||||||
|
|
||||||
comment = argv.reject { |x| x == '-m' }.join(' ')
|
|
||||||
comment = "#{parts[:feature]}: #{comment}"
|
|
||||||
|
|
||||||
git_commit comment
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
|
||||||
@@ -5,6 +5,7 @@ require_relative './rebase'
|
|||||||
require_relative './merge_to'
|
require_relative './merge_to'
|
||||||
require_relative './tab'
|
require_relative './tab'
|
||||||
require_relative './branch'
|
require_relative './branch'
|
||||||
|
require_relative './commit'
|
||||||
|
|
||||||
module Feature
|
module Feature
|
||||||
|
|
||||||
@@ -19,6 +20,7 @@ module Feature
|
|||||||
when "rebase" then Feature::Rebase.new(argv)
|
when "rebase" then Feature::Rebase.new(argv)
|
||||||
when "merge" then Feature::MergeTo.new(argv)
|
when "merge" then Feature::MergeTo.new(argv)
|
||||||
when "tab" then Feature::Tab.new(argv)
|
when "tab" then Feature::Tab.new(argv)
|
||||||
|
when "commit" then Feature::Commit.new(argv)
|
||||||
else Feature::Branch.new(argv)
|
else Feature::Branch.new(argv)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -36,7 +38,7 @@ module Feature
|
|||||||
end
|
end
|
||||||
|
|
||||||
def self.tab_completion
|
def self.tab_completion
|
||||||
[:start, :end, :trash, :rebase, :merge].map(&:to_s).sort
|
[:start, :end, :trash, :rebase, :merge, :commit].map(&:to_s).sort
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
27
lib/feature/commit.rb
Normal file
27
lib/feature/commit.rb
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
require_relative './base'
|
||||||
|
|
||||||
|
module Feature
|
||||||
|
|
||||||
|
class Commit < Feature::Base
|
||||||
|
def valid?
|
||||||
|
argv.size > 1
|
||||||
|
end
|
||||||
|
|
||||||
|
def help
|
||||||
|
puts
|
||||||
|
puts "USAGE: feature commit [word....]"
|
||||||
|
puts
|
||||||
|
exit
|
||||||
|
end
|
||||||
|
|
||||||
|
def execute
|
||||||
|
parts = parse_branch(current_branch)
|
||||||
|
|
||||||
|
comment = argv.reject { |x| x == '-m' }.join(' ')
|
||||||
|
comment = "#{parts[:feature]}: #{comment}"
|
||||||
|
|
||||||
|
git_commit comment
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
Reference in New Issue
Block a user