Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ Usage::
{repository,sshkey} The main command
repository Manage your repository
sshkey Manage your sshkey
clone Clone your repository
push Add, commit and push to your repository

optional arguments:
-h, --help show this help message and exit
Expand Down Expand Up @@ -51,6 +53,20 @@ SSHKey ::
optional arguments:
-h, --help show this help message and exit

Clone ::

usage: blih clone <name> ...

positional arguments:
<name> Name of your repository

Push ::

usage: blih push <message> ...

positional arguments:
<message> Message of your commit


.. |build-status| image:: https://circleci.com/gh/bocal/blih.svg?&style=shield
:target: https://circleci.com/gh/bocal/blih
46 changes: 44 additions & 2 deletions blih/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

#-
Expand Down Expand Up @@ -34,6 +34,7 @@

import sys
import os
import git

from argparse import ArgumentParser
import getpass
Expand Down Expand Up @@ -230,6 +231,31 @@ def sshkey_delete(user, password, comment, **kwargs):
return {'data' : data,
'format' : ''}

# pylint: disable=unused-argument
def clone_from_repository(user, password, name, **kwargs):
"""
Git clone from repository
"""
g = git.cmd.Git(os.getcwd())
git_url = 'git@git.epitech.eu:/' + user + '/' + name
g.clone(git_url)

#pylink: disable=unused-argument
def push_to_repository(user, password, message, **kwargs):
"""
Git add, commit and push to repository
"""
repo = git.Repo(os.getcwd())
# files = repo.git.diff(None, name_only=True)
# for f in files.split('\n'):
# show_diff(f)
# repo.git.add(f)
repo.git.add(A=True)

repo.git.commit('-m', message)
repo.git.push('origin', 'master')


#pylint: disable=R0914,too-many-statements
def main():
"""
Expand Down Expand Up @@ -283,7 +309,7 @@ def main():
)
parser_repo_info.add_argument('name', help='The repository name')
parser_repo_info.set_defaults(func=repository_info)

parser_repo_list = subparser_repository.add_parser(
'list',
help='Get the list of your repositories'
Expand Down Expand Up @@ -348,6 +374,22 @@ def main():
parser_sshkey_delete.add_argument('comment', help='The comment of the sshkey file to delete')
parser_sshkey_delete.set_defaults(func=sshkey_delete)

# Git functionality in BLIH

parser_clone = subparser.add_parser(
'clone',
help='Use git clone'
)
parser_clone.add_argument('name', help='The repository name')
parser_clone.set_defaults(func=clone_from_repository)

parser_push = subparser.add_parser(
'push',
help='Use git push'
)
parser_push.add_argument('message', help='Commit message')
parser_push.set_defaults(func=push_to_repository)

argument = parser.parse_args()

if argument.password == None:
Expand Down
Binary file added blih/__init__.pyc
Binary file not shown.