def load_repo(client, path=None, index='git'):
 path = (dirname(dirname(abspath(__file__))) if (path is None) else path)
 repo_name = basename(path)
 repo = git.Repo(path)
 create_git_index(client, index)
 client.create(index=index, doc_type='repos', id=repo_name, body={}, ignore=409)
 for (ok, result) in streaming_bulk(client, parse_commits(repo.refs.master.commit, repo_name), index=index, doc_type='commits', chunk_size=50):
  (action, result) = result.popitem()
  doc_id = ('/%s/commits/%s' % (index, result['_id']))
  if (not ok):
   print(('Failed to %s document %s: %r' % (action, doc_id, result)))
  else:
   print(doc_id)

def load_repo ( client , path = None , index = 'git' ) : path = ( dirname ( dirname ( abspath ( __file__ ) ) ) if ( path is None ) else path ) repo_name = basename ( path ) repo = git . Repo ( path ) create_git_index ( client , index ) client . create ( index = index , doc_type = 'repos' , id = repo_name , body = { } , ignore = 409 ) for ( ok , result ) in streaming_bulk ( client , parse_commits ( repo . refs . master . commit , repo_name ) , index = index , doc_type = 'commits' , chunk_size = 50 ) : ( action , result ) = result . popitem ( ) doc_id = ( '/%s/commits/%s' % ( index , result [ '_id' ] ) ) if ( not ok ) : print ( ( 'Failed to %s document %s: %r' % ( action , doc_id , result ) ) ) else : print ( doc_id )
parse a git repository with all its commits and load it into elasticsearch using client .