gitmaker 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,5 @@
1
+ lib/**/*.rb
2
+ bin/*
3
+ -
4
+ features/**/*.feature
5
+ LICENSE.txt
@@ -0,0 +1,3 @@
1
+ pkg/*
2
+ *.gem
3
+ .bundle
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in gitmaker.gemspec
4
+ gemspec
@@ -0,0 +1,2 @@
1
+ require 'bundler'
2
+ Bundler::GemHelper.install_tasks
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'gitmaker'
4
+
5
+ gm = Gitmaker::Gitmaker.new(ARGV[0])
6
+ puts gm.read_config
7
+ puts gm.create_git_repo
8
+ puts gm.migrate_repo
@@ -0,0 +1,22 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "gitmaker/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "gitmaker"
7
+ s.version = Gitmaker::VERSION
8
+ s.platform = Gem::Platform::RUBY
9
+ s.authors = ["Julius F"]
10
+ s.email = ["baldrailers@gmail.com"]
11
+ s.homepage = ""
12
+ s.summary = %q{A simple tool that helps creating git repositories}
13
+ s.description = %q{Build your git repository}
14
+
15
+ s.rubyforge_project = "gitmaker"
16
+
17
+ s.files = `git ls-files`.split("\n")
18
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
19
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
20
+ s.require_paths = ["lib"]
21
+
22
+ end
@@ -0,0 +1,51 @@
1
+ require "yaml"
2
+ require "net/ssh"
3
+ require "find"
4
+ require "fileutils"
5
+
6
+ module Gitmaker
7
+ class Gitmaker
8
+ def initialize(repository)
9
+ @repository = repository
10
+ end
11
+
12
+ def read_config
13
+ config = YAML.load_file("#{ENV['HOME']}/.gitmaker")
14
+ @server_ip = config['config']['server_ip']
15
+ @git_user = config['config']['git_user']
16
+ @git_pass = config['config']['git_pass']
17
+ @git_base_repo = config['config']['git_base_repo']
18
+ end
19
+
20
+ def create_git_repo
21
+ Net::SSH.start(@server_ip, @git_user, :password => @git_pass) do |ssh|
22
+ puts "Adding repository"
23
+ result1 = ssh.exec!("mkdir -p #{@git_base_repo}/#{@repository}.git ")
24
+ puts result1
25
+ result2 = ssh.exec!("cd #{@git_base_repo}/#{@repository}.git && /usr/bin/git --bare init")
26
+ puts result2
27
+ end
28
+ end
29
+
30
+ def migrate_repo
31
+ system "cat .gitignore > /tmp/temp_gitignore"
32
+ clean_git
33
+ system "mv /tmp/temp_gitignore .gitignore"
34
+ system "git init"
35
+ system "git remote add origin #{@git_user}@#{@server_ip}:#{@git_base_repo}/#{@repository}.git"
36
+ system "git add *"
37
+ system "git add .gitignore"
38
+ system "git commit -a -m 'Base application'"
39
+ system "git push origin master:refs/heads/master"
40
+ end
41
+
42
+ def clean_git
43
+ Find.find('./') do |path|
44
+ if File.basename(path) == '.git'
45
+ FileUtils.remove_dir(path, true)
46
+ Find.prune
47
+ end
48
+ end
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,3 @@
1
+ module Gitmaker
2
+ VERSION = "0.0.4"
3
+ end
metadata ADDED
@@ -0,0 +1,75 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: gitmaker
3
+ version: !ruby/object:Gem::Version
4
+ hash: 23
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 0
9
+ - 4
10
+ version: 0.0.4
11
+ platform: ruby
12
+ authors:
13
+ - Julius F
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2010-12-11 00:00:00 +08:00
19
+ default_executable:
20
+ dependencies: []
21
+
22
+ description: Build your git repository
23
+ email:
24
+ - baldrailers@gmail.com
25
+ executables:
26
+ - gitmaker
27
+ extensions: []
28
+
29
+ extra_rdoc_files: []
30
+
31
+ files:
32
+ - .document
33
+ - .gitignore
34
+ - Gemfile
35
+ - Rakefile
36
+ - bin/gitmaker
37
+ - gitmaker.gemspec
38
+ - lib/gitmaker.rb
39
+ - lib/gitmaker/version.rb
40
+ has_rdoc: true
41
+ homepage: ""
42
+ licenses: []
43
+
44
+ post_install_message:
45
+ rdoc_options: []
46
+
47
+ require_paths:
48
+ - lib
49
+ required_ruby_version: !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ hash: 3
55
+ segments:
56
+ - 0
57
+ version: "0"
58
+ required_rubygems_version: !ruby/object:Gem::Requirement
59
+ none: false
60
+ requirements:
61
+ - - ">="
62
+ - !ruby/object:Gem::Version
63
+ hash: 3
64
+ segments:
65
+ - 0
66
+ version: "0"
67
+ requirements: []
68
+
69
+ rubyforge_project: gitmaker
70
+ rubygems_version: 1.3.7
71
+ signing_key:
72
+ specification_version: 3
73
+ summary: A simple tool that helps creating git repositories
74
+ test_files: []
75
+