Skip to content
Browse files

master branch now created on startup

Section creation has the option of supplying content as well
  • Loading branch information...
1 parent eba427c commit ffc6984a0ebc97bd5c9e7642baea06d4926c562d @obmarg committed May 29, 2012
Showing with 19 additions and 2 deletions.
  1. +19 −2 doc.py
View
21 doc.py
@@ -73,6 +73,7 @@ class Document(object):
Class representing a document, interacts with the git
database
'''
+ MASTER_REF = 'refs/heads/master'
SECTION_REF_PREFIX = 'refs/heads/sections/'
def __init__( self, name, create=False ):
@@ -87,9 +88,20 @@ def __init__( self, name, create=False ):
if create:
# Create a bare repository
self.repo = init_repository( targetDir, True )
+ self._CreateMasterBranch()
else:
self.repo = Repository( targetDir )
+ def _CreateMasterBranch( self ):
+ '''
+ Creates the master branch on the repo w/ default file.
+ For now this is just a file named layout
+ '''
+ commitId = CommitBlob(
+ self.repo, '', 'layout', 'Initial commit'
+ )
+ self.repo.create_reference( self.MASTER_REF, commitId )
+
@classmethod
def _IsSectionRef( cls, refName ):
'''
@@ -134,16 +146,21 @@ def Sections( self ):
for name, ref in self._SectionRefs()
)
- def AddSection( self, name ):
+ def AddSection( self, name, content='' ):
'''
Creates a new section
+ Args:
+ name The name of the section
+ content The optional initial content of the
+ section
+
Returns:
The new Section object
'''
commitId = CommitBlob(
self.repo,
- '',
+ content,
name,
'Created section ' + name
)

0 comments on commit ffc6984

Please sign in to comment.
Something went wrong with that request. Please try again.