flit 0.1.pre
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +2 -0
- data/LICENCE +8 -0
- data/README.md +62 -0
- data/Rakefile +34 -0
- data/VERSION +1 -0
- data/bin/flit +9 -0
- data/lib/flit.rb +52 -0
- data/lib/flit/cli.rb +8 -0
- data/lib/flit/commands.rb +45 -0
- data/lib/flit/commands/finish.rb +14 -0
- data/lib/flit/commands/init.rb +54 -0
- data/lib/flit/commands/start.rb +33 -0
- data/lib/flit/commands/stop.rb +14 -0
- data/lib/flit/commands/version.rb +12 -0
- data/lib/flit/extensions/string.rb +11 -0
- data/lib/flit/help.rb +63 -0
- data/lib/flit/version.rb +5 -0
- metadata +96 -0
data/History.txt
ADDED
data/LICENCE
ADDED
@@ -0,0 +1,8 @@
|
|
1
|
+
Flit
|
2
|
+
Copyright (C) 2010 Matt Kirman <matt@mattkirman.com>
|
3
|
+
|
4
|
+
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
|
5
|
+
|
6
|
+
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
7
|
+
|
8
|
+
You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
data/README.md
ADDED
@@ -0,0 +1,62 @@
|
|
1
|
+
#Flit
|
2
|
+
|
3
|
+
Flit contains super simple branch management extensions for Git. It aims to give quick repository functions to improve a typical Git workflow as described at [http://mattkirman.com/2010/08/27/my-git-workflow-introducing-flit/](http://mattkirman.com/2010/08/27/my-git-workflow-introducing-flit/).
|
4
|
+
|
5
|
+
_Flit is an extremely early alpha. Features may be broken or just plain missing, but getting this code out into the open-source community where people can start hacking away with it is much more important. If something’s missing just fork the code, add your fix and send me a pull request._
|
6
|
+
|
7
|
+
|
8
|
+
##Installation
|
9
|
+
|
10
|
+
The easiest way to install Flit is through RubyGems:
|
11
|
+
|
12
|
+
gem install flit --pre
|
13
|
+
|
14
|
+
|
15
|
+
##Usage
|
16
|
+
|
17
|
+
Flit is capable of being used with both existing and brand new Git repositories. You will also be asked a number of questions so that we can set up your repository as you would like. For the majority of installations it is perfectly safe to use the default, suggested, settings. To initialise a Flit powered Git repository simply run:
|
18
|
+
|
19
|
+
flit init
|
20
|
+
|
21
|
+
_**Please note:** Flit commands can only be run from the top level directory of your Git repository. This will be rectified in future releases._
|
22
|
+
|
23
|
+
|
24
|
+
###Working with branches
|
25
|
+
|
26
|
+
Flit expects that you work on features and bugfixes in different, topic specific, branches. When switching branches Flit doesn't care whether the branch already exists, if it doesn't exist it will be created in the background. Currently you can only work in `feature` or `bugfix` branches.
|
27
|
+
|
28
|
+
When starting work on a new feature or bugfix use the following commands:
|
29
|
+
|
30
|
+
flit start feature the_name_of_my_new_feature
|
31
|
+
flit start bugfix the_issue_number_of_the_bug
|
32
|
+
|
33
|
+
You can now go ahead and committing your code as normal. Once you're ready to stop work for the day on your feature or bugfix, and want to return to your development branch, run:
|
34
|
+
|
35
|
+
flit stop
|
36
|
+
|
37
|
+
_**Please note:** This will not automatically commit your code. You will have to do a `git commit` before running `flit stop`._
|
38
|
+
|
39
|
+
Once your code is finished and you're ready to merge it back into your development branch you'll need to use the `finish` command:
|
40
|
+
|
41
|
+
flit finish feature the_name_of_my_new_feature
|
42
|
+
flit finish bugfix the_issue_number_of_the_bug
|
43
|
+
|
44
|
+
This will pull down changes in master, rebase them into your feature branch and then merge your feature back into master.
|
45
|
+
|
46
|
+
|
47
|
+
##Contributing
|
48
|
+
|
49
|
+
You want to contribute? Great!
|
50
|
+
|
51
|
+
1. Fork Flit
|
52
|
+
2. Create a new feature branch (`flit start feature my_feature`)
|
53
|
+
3. Commit your changes (`git commit -am "Added my feature"`)
|
54
|
+
4. Push the branch (`git push origin feature/my_feature`)
|
55
|
+
5. Send me a pull request
|
56
|
+
|
57
|
+
I won't accept any pull requests if your feature is on the `master` branch as this makes it more difficult to cherry-pick your changes in. Also, please don't be offended if I don't pull your changes in immediately. I'll bring them in when I've got time.
|
58
|
+
|
59
|
+
|
60
|
+
##Licence
|
61
|
+
|
62
|
+
See LICENCE.
|
data/Rakefile
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'rake'
|
2
|
+
require 'rdoc/task'
|
3
|
+
require 'rake/gempackagetask'
|
4
|
+
|
5
|
+
|
6
|
+
desc "Run all tests by default"
|
7
|
+
task :default => :test
|
8
|
+
|
9
|
+
|
10
|
+
desc "Run tests"
|
11
|
+
task :test do
|
12
|
+
|
13
|
+
end
|
14
|
+
|
15
|
+
|
16
|
+
desc "Install the gem for testing locally"
|
17
|
+
task :install => :repackage do
|
18
|
+
version = File.read("VERSION").strip
|
19
|
+
system("gem install pkg/flit-#{version}.gem --no-ri --no-rdoc")
|
20
|
+
end
|
21
|
+
|
22
|
+
|
23
|
+
spec = eval(File.read('flit.gemspec'))
|
24
|
+
Rake::GemPackageTask.new(spec) do |pkg|
|
25
|
+
pkg.gem_spec = spec
|
26
|
+
end
|
27
|
+
|
28
|
+
|
29
|
+
desc "Push the gem to gemcutter"
|
30
|
+
task :release do
|
31
|
+
require 'rake/gemcutter'
|
32
|
+
Rake::Gemcutter::Tasks.new(spec).define
|
33
|
+
Rake::Task['gem:push'].invoke
|
34
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.1.pre
|
data/bin/flit
ADDED
data/lib/flit.rb
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'yaml'
|
3
|
+
require 'highline'
|
4
|
+
|
5
|
+
|
6
|
+
module Flit
|
7
|
+
autoload :Help, 'flit/help'
|
8
|
+
autoload :Version, 'flit/version'
|
9
|
+
|
10
|
+
|
11
|
+
module Commands
|
12
|
+
autoload :Base, "flit/commands"
|
13
|
+
autoload :Init, "flit/commands/init"
|
14
|
+
autoload :Start, "flit/commands/start"
|
15
|
+
autoload :Stop, "flit/commands/stop"
|
16
|
+
autoload :Finish, "flit/commands/finish"
|
17
|
+
autoload :Version, "flit/commands/version"
|
18
|
+
end
|
19
|
+
|
20
|
+
|
21
|
+
def self.exec_script!
|
22
|
+
if %w(--version -v).include? ARGV.first
|
23
|
+
puts "Flit #{Version::STRING}"
|
24
|
+
|
25
|
+
elsif ARGV[0].nil? || %w(help --help -h).include?(ARGV.first)
|
26
|
+
puts Help.display
|
27
|
+
|
28
|
+
else
|
29
|
+
command = ARGV.first
|
30
|
+
|
31
|
+
begin
|
32
|
+
klass = eval "Commands::#{command.camelize}.new"
|
33
|
+
klass.extend Commands::Base
|
34
|
+
begin
|
35
|
+
klass.run ARGV[1..-1]
|
36
|
+
rescue
|
37
|
+
klass.run
|
38
|
+
end
|
39
|
+
rescue
|
40
|
+
puts "flit: '#{command}' is not a command. See 'flit help'."
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
47
|
+
|
48
|
+
|
49
|
+
# Load our custom extensions
|
50
|
+
Dir[File.join(File.dirname(__FILE__), 'flit', 'extensions', '*.rb')].each do |extension|
|
51
|
+
require extension
|
52
|
+
end
|
data/lib/flit/cli.rb
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
module Flit
|
2
|
+
module Commands
|
3
|
+
module Base
|
4
|
+
|
5
|
+
def working_directory
|
6
|
+
`pwd`.gsub("\n", '')
|
7
|
+
end
|
8
|
+
|
9
|
+
|
10
|
+
def fatal(string)
|
11
|
+
puts "fatal: #{string}"
|
12
|
+
exit(0)
|
13
|
+
end
|
14
|
+
|
15
|
+
|
16
|
+
def is_flit?(path = nil)
|
17
|
+
path ||= "#{working_directory}/.flit_config"
|
18
|
+
File.exists? path
|
19
|
+
end
|
20
|
+
|
21
|
+
|
22
|
+
def is_git?(path = nil)
|
23
|
+
path ||= "#{working_directory}/.git"
|
24
|
+
File.directory? path
|
25
|
+
end
|
26
|
+
|
27
|
+
|
28
|
+
def save_config(config)
|
29
|
+
File.open(".flit_config",'w') { |f| f.puts config.to_yaml }
|
30
|
+
end
|
31
|
+
|
32
|
+
|
33
|
+
def open_config
|
34
|
+
YAML::load(File.open('.flit_config'))
|
35
|
+
end
|
36
|
+
|
37
|
+
|
38
|
+
def show_help
|
39
|
+
puts Flit::Help.display_for_command(self.class.name)
|
40
|
+
exit(0)
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module Flit
|
2
|
+
module Commands
|
3
|
+
class Finish
|
4
|
+
DESC = "Finish up a feature or bugfix and merge it back into the development branch"
|
5
|
+
|
6
|
+
def run(args)
|
7
|
+
# TODO: Show the help page if no options are set
|
8
|
+
|
9
|
+
puts "flit: not implemented yet"
|
10
|
+
end
|
11
|
+
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
module Flit
|
2
|
+
module Commands
|
3
|
+
class Init
|
4
|
+
DESC = "Create a new Flit repository"
|
5
|
+
|
6
|
+
def run
|
7
|
+
# Don't allow us to reinitialise an existing Flit repository
|
8
|
+
if is_flit?
|
9
|
+
fatal "directory is already a flit repository"
|
10
|
+
end
|
11
|
+
|
12
|
+
# Don't allow us to reinitialise an existing Git repository
|
13
|
+
unless is_git?
|
14
|
+
puts "Creating a new repository..."
|
15
|
+
`git init`
|
16
|
+
end
|
17
|
+
|
18
|
+
|
19
|
+
# Set up our initial config
|
20
|
+
puts "No branches exist yet. Base branches must be created now."
|
21
|
+
|
22
|
+
h = HighLine.new
|
23
|
+
|
24
|
+
bleeding_edge_branch_name = h.ask("Branch name for bleeding edge development: ") { |q| q.default = 'master' }
|
25
|
+
staging_branch_name = h.ask("Branch name for staging releases: ") { |q| q.default = 'staging' }
|
26
|
+
production_branch_name = h.ask("Branch name for production releases: ") { |q| q.default = 'production' }
|
27
|
+
|
28
|
+
puts "Name your supporting branch prefixes."
|
29
|
+
|
30
|
+
feature_branch_prefix = h.ask("Feature branches? ") { |q| q.default = 'feature/' }
|
31
|
+
bugfix_branch_prefix = h.ask("Bugfix branches? ") { |q| q.default = 'bugfix/' }
|
32
|
+
version_tag_prefix = h.ask("Version tag prefix? ") { |q| q.default = 'v' }
|
33
|
+
|
34
|
+
|
35
|
+
# Save our config
|
36
|
+
save_config ({
|
37
|
+
:branches => {
|
38
|
+
:bleeding_edge => bleeding_edge_branch_name,
|
39
|
+
:staging => staging_branch_name,
|
40
|
+
:production => production_branch_name,
|
41
|
+
:feature_prefix => feature_branch_prefix,
|
42
|
+
:bugfix_prefix => bugfix_branch_prefix
|
43
|
+
},
|
44
|
+
:tags => {
|
45
|
+
:version_prefix => version_tag_prefix
|
46
|
+
}
|
47
|
+
})
|
48
|
+
|
49
|
+
# Repository created!
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module Flit
|
2
|
+
module Commands
|
3
|
+
class Start
|
4
|
+
DESC = "Start work on a new feature or bugfix"
|
5
|
+
USAGE = "TYPE NAME"
|
6
|
+
OPTIONS = {
|
7
|
+
:type => "Can be either a feature or bugfix",
|
8
|
+
:name => "The name of your feature or bugfix",
|
9
|
+
}
|
10
|
+
|
11
|
+
def run(args)
|
12
|
+
# Gatekeepers
|
13
|
+
fatal "directory isn't a flit repository" unless is_flit?
|
14
|
+
show_help unless args.count == 2
|
15
|
+
|
16
|
+
type, name = args
|
17
|
+
config = open_config
|
18
|
+
|
19
|
+
branch_name = case type
|
20
|
+
when "feature" then config[:branches][:feature_prefix]
|
21
|
+
when "bugfix" then config[:branches][:bugfix_prefix]
|
22
|
+
else puts "flit: unknown branch type '#{type}'"; exit(0)
|
23
|
+
end
|
24
|
+
|
25
|
+
branch_name << name
|
26
|
+
|
27
|
+
`git branch #{branch_name}` if `git branch`.match(branch_name).nil?
|
28
|
+
`git checkout #{branch_name}`
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
class String
|
2
|
+
|
3
|
+
def camelize(first_letter_in_uppercase = true)
|
4
|
+
if first_letter_in_uppercase
|
5
|
+
self.to_s.gsub(/\/(.?)/) { "::#{$1.upcase}" }.gsub(/(?:^|_)(.)/) { $1.upcase }
|
6
|
+
else
|
7
|
+
self.to_s[0].chr.downcase + camelize(lower_case_and_underscored_word)[1..-1]
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
end
|
data/lib/flit/help.rb
ADDED
@@ -0,0 +1,63 @@
|
|
1
|
+
module Flit
|
2
|
+
class Help
|
3
|
+
USAGE = <<USAGE
|
4
|
+
Usage:
|
5
|
+
flit COMMAND [options]
|
6
|
+
|
7
|
+
Commands:
|
8
|
+
{{commands}}
|
9
|
+
|
10
|
+
help # Show this page
|
11
|
+
-v, --version # Get Flit version information
|
12
|
+
|
13
|
+
USAGE
|
14
|
+
|
15
|
+
|
16
|
+
def self.display
|
17
|
+
USAGE.gsub("{{commands}}", available_commands)
|
18
|
+
end
|
19
|
+
|
20
|
+
|
21
|
+
def self.available_commands
|
22
|
+
commands_dir = File.expand_path('../commands', __FILE__)
|
23
|
+
commands = []
|
24
|
+
Dir.new(commands_dir).each do |f|
|
25
|
+
if f.match(/(.*)\.rb/)
|
26
|
+
begin
|
27
|
+
command = f.gsub(/\.rb/, '')
|
28
|
+
klass = "Flit::Commands::#{command.camelize}"
|
29
|
+
commands << "#{command.ljust(20)}# #{ eval("#{klass}::DESC") }"
|
30
|
+
rescue
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
commands.sort.join("\n ")
|
36
|
+
end
|
37
|
+
|
38
|
+
|
39
|
+
def self.display_for_command(klass)
|
40
|
+
command = klass.split(/::/)[-1].downcase
|
41
|
+
|
42
|
+
help = "Usage:\n flit #{command}"
|
43
|
+
begin
|
44
|
+
help << " #{eval("#{klass}::USAGE")}"
|
45
|
+
rescue
|
46
|
+
end
|
47
|
+
|
48
|
+
begin
|
49
|
+
options = eval("#{klass}::OPTIONS")
|
50
|
+
unless options.count == 0
|
51
|
+
help << "\n\nOptions:"
|
52
|
+
options.each do |opt, desc|
|
53
|
+
help << "\n #{opt.to_s.ljust(20)}# #{desc}"
|
54
|
+
end
|
55
|
+
end
|
56
|
+
rescue
|
57
|
+
end
|
58
|
+
|
59
|
+
"#{help}\n "
|
60
|
+
end
|
61
|
+
|
62
|
+
end
|
63
|
+
end
|
data/lib/flit/version.rb
ADDED
metadata
ADDED
@@ -0,0 +1,96 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: flit
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: true
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 1
|
8
|
+
- pre
|
9
|
+
version: 0.1.pre
|
10
|
+
platform: ruby
|
11
|
+
authors:
|
12
|
+
- Matt Kirman
|
13
|
+
autorequire:
|
14
|
+
bindir: bin
|
15
|
+
cert_chain: []
|
16
|
+
|
17
|
+
date: 2010-08-28 00:00:00 +01:00
|
18
|
+
default_executable: flit
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
21
|
+
name: highline
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
none: false
|
25
|
+
requirements:
|
26
|
+
- - ">="
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
segments:
|
29
|
+
- 0
|
30
|
+
version: "0"
|
31
|
+
type: :runtime
|
32
|
+
version_requirements: *id001
|
33
|
+
description: Flit contains super simple branch management extensions for Git. It aims to give quick repository functions to improve a typical Git workflow.
|
34
|
+
email: matt@mattkirman.com
|
35
|
+
executables:
|
36
|
+
- flit
|
37
|
+
extensions: []
|
38
|
+
|
39
|
+
extra_rdoc_files: []
|
40
|
+
|
41
|
+
files:
|
42
|
+
- History.txt
|
43
|
+
- LICENCE
|
44
|
+
- Rakefile
|
45
|
+
- README.md
|
46
|
+
- VERSION
|
47
|
+
- lib/flit.rb
|
48
|
+
- lib/flit/cli.rb
|
49
|
+
- lib/flit/commands.rb
|
50
|
+
- lib/flit/help.rb
|
51
|
+
- lib/flit/version.rb
|
52
|
+
- lib/flit/commands/finish.rb
|
53
|
+
- lib/flit/commands/init.rb
|
54
|
+
- lib/flit/commands/start.rb
|
55
|
+
- lib/flit/commands/stop.rb
|
56
|
+
- lib/flit/commands/version.rb
|
57
|
+
- lib/flit/extensions/string.rb
|
58
|
+
- bin/flit
|
59
|
+
has_rdoc: true
|
60
|
+
homepage: http://github.com/mattkirman/flit
|
61
|
+
licenses: []
|
62
|
+
|
63
|
+
post_install_message:
|
64
|
+
rdoc_options: []
|
65
|
+
|
66
|
+
require_paths:
|
67
|
+
- lib
|
68
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
69
|
+
none: false
|
70
|
+
requirements:
|
71
|
+
- - ">="
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
segments:
|
74
|
+
- 1
|
75
|
+
- 8
|
76
|
+
- 7
|
77
|
+
version: 1.8.7
|
78
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
79
|
+
none: false
|
80
|
+
requirements:
|
81
|
+
- - ">="
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
segments:
|
84
|
+
- 1
|
85
|
+
- 3
|
86
|
+
- 6
|
87
|
+
version: 1.3.6
|
88
|
+
requirements: []
|
89
|
+
|
90
|
+
rubyforge_project:
|
91
|
+
rubygems_version: 1.3.7
|
92
|
+
signing_key:
|
93
|
+
specification_version: 3
|
94
|
+
summary: Branch management extensions for Git
|
95
|
+
test_files: []
|
96
|
+
|