Class: Git::Helper
- Inherits:
-
Object
- Object
- Git::Helper
- Defined in:
- lib/it_tools/git.rb
Instance Attribute Summary collapse
-
#log ⇒ Object
Returns the value of attribute log.
-
#ops ⇒ Object
Returns the value of attribute ops.
Instance Method Summary collapse
- #get_dirname(dir) ⇒ Object
-
#initialize ⇒ Helper
constructor
A new instance of Helper.
-
#remove_git_repo(dir = '.') ⇒ Object
-.
-
#setup_new_project(project_dir = '.', int_gitosis_dir = '../gitosis-admin', ext_gitosis_dir = '../spicevan/gitosis-admin', int_repo = '[email protected]', ext_repo = '[email protected]', gitosis_group = 'beta_projects') ⇒ Object
When executed in a new folder it will * initialize a git repository there.
Constructor Details
#initialize ⇒ Helper
Returns a new instance of Helper.
12 13 14 15 16 17 18 19 20 |
# File 'lib/it_tools/git.rb', line 12 def initialize @ops = {} @log = Logger.new 'log.txt' if level = @ops[:debug_level] @log.level = level else @log.level = Logger::DEBUG end end |
Instance Attribute Details
#log ⇒ Object
Returns the value of attribute log.
11 12 13 |
# File 'lib/it_tools/git.rb', line 11 def log @log end |
#ops ⇒ Object
Returns the value of attribute ops.
11 12 13 |
# File 'lib/it_tools/git.rb', line 11 def ops @ops end |
Instance Method Details
#get_dirname(dir) ⇒ Object
52 53 54 55 56 57 58 |
# File 'lib/it_tools/git.rb', line 52 def get_dirname dir file = File.new dir path = File.absolute_path file path_array = path.split '/' dirname = path_array.last return dirname end |
#remove_git_repo(dir = '.') ⇒ Object
-
62 63 64 |
# File 'lib/it_tools/git.rb', line 62 def remove_git_repo dir = '.' FileUtils.rm_rf (File.join(dir,'.git')) end |
#setup_new_project(project_dir = '.', int_gitosis_dir = '../gitosis-admin', ext_gitosis_dir = '../spicevan/gitosis-admin', int_repo = '[email protected]', ext_repo = '[email protected]', gitosis_group = 'beta_projects') ⇒ Object
When executed in a new folder it will
-
initialize a git repository there.
-
It will add two remote repositories, an internal and an external repo.
-
It will add the project into gitosis (int/ext)
-
and it will do an initial commit, into either the internal or exteral repository, depending if you are on the VPN or not.
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/it_tools/git.rb', line 27 def setup_new_project project_dir = '.', int_gitosis_dir = '../gitosis-admin', ext_gitosis_dir = '../spicevan/gitosis-admin', int_repo = '[email protected]', ext_repo = '[email protected]', gitosis_group = 'beta_projects' dirname = get_dirname project_dir @log.info "Project dir: " + dirname g = Git.init project_dir repo_tail = ":" + dirname + ".git" g.add_remote 'origin', int_repo + repo_tail g.add_remote 'spicevan', ext_repo + repo_tail g.add '.' g.commit 'initial commit' gitosis = Git::Gitosis.new gitosis_conf = 'gitosis.conf' remote_name = 'spicevan' gitosis_file = File.join ext_gitosis_dir, gitosis_conf gitosis.add_project_to_gitosis dirname, gitosis_group, gitosis_file, gitosis_file gtss = Git.open ext_gitosis_dir gtss.add 'gitosis.conf' gtss.commit '.' gtss.push(gtss.remote( 'origin' )) g.push(g.remote( remote_name )) end |