Skip to content

Commit

Permalink
Adds git repository, and initial commit.
Browse files Browse the repository at this point in the history
Signed-off-by: Kouhei Maeda <mkouhei@palmtb.net>
  • Loading branch information
mkouhei committed Feb 18, 2016
1 parent 46a6ea5 commit 2b12878
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 1 deletion.
1 change: 1 addition & 0 deletions bootstrap_py/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ def main():
pkg_tree = control.PackageTree(pkg_data)
pkg_tree.generate()
pkg_tree.move()
pkg_tree.vcs_init()
except (RuntimeError, BackendFailure, Conflict) as exc:
sys.stderr.write('{0}\n'.format(exc))
sys.exit(1)
Expand Down
5 changes: 5 additions & 0 deletions bootstrap_py/control.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from datetime import datetime
from jinja2 import PackageLoader, Environment
from bootstrap_py.classifiers import Classifiers
from bootstrap_py.vcs import VCS
from bootstrap_py.docs import build_sphinx


Expand Down Expand Up @@ -140,3 +141,7 @@ def generate(self):
self._generate_dirs()
self._generate_init()
self._generate_files()

def vcs_init(self):
"""Initialize VCS repository."""
VCS(os.path.join(self.outdir, self.name), self.pkg_data)
44 changes: 44 additions & 0 deletions bootstrap_py/vcs.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# -*- coding: utf-8 -*-
"""bootstrap_py.vcs."""
import git


class VCS(object):
"""VCS class."""

def __init__(self, repo_dir, metadata):
"""Initialize."""
self.metadata = metadata
# repo_dir is outdir
self.repo = git.Git(repo_dir)
self.init()
self.config()
self.add_index()
self.initial_commit()
if hasattr(self.metadata, 'username') and self.metadata.username:
self.remote_add()

def init(self):
"""git init."""
self.repo.init()

def add_index(self):
"""git add ."""
self.repo.add('.')

def config(self):
"""git config."""
self.repo.config('user.name', self.metadata.author)
self.repo.config('user.email', self.metadata.email)

def initial_commit(self):
"""initial commit."""
self.repo.commit('-m', 'Initial commit.')

def remote_add(self):
"""git remote add."""
self.repo.remote('add',
'origin',
'git@github.com:{username}/{repo}.git'.format(
username=self.metadata.username,
repo=self.metadata.name))
3 changes: 2 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ def read_content(filepath):
requires = ['setuptools',
'Jinja2',
'Sphinx',
'requests']
'requests',
'GitPython']
extras_require = {
'reST': ['Sphinx'],
}
Expand Down

0 comments on commit 2b12878

Please sign in to comment.