Example #1
0
def create_work_path():
    for root, dirs, files in os.walk(repo_path, topdown=False):
        for name in files:
            os.remove(os.path.join(root, name))
        for name in dirs:
            os.rmdir(os.path.join(root, name))

    if not os.path.exists(repo_path):
        os.mkdir(repo_path)

    if not os.path.exists("%s/.git" % repo_path):
        Gittle.init(repo_path)

    return None
Example #2
0
 def init(path):
     try:
         repo = Gittle.init(path)
         return repo
     except:
         AgentGitHandler.log.exception("Initializing local repo at %r failed" % path)
         raise Exception("Initializing local repo at %r failed" % path)
Example #3
0
 def init_repo_if_empty(self,repo_name):
     repopath=os.path.join(self.view['repo'].base,repo_name)
     self.g= Gittle.init(repopath,bare=False )
     self.g.commit('name','email','initial commit')
     self.view['repo'].text=repo_name
     console.hud_alert('Repo {} created'.format(repo_name))
     self.did_select_repo(self.view['repo'])
Example #4
0
 def init_repo_if_empty(self, repo_name):
     repopath = os.path.join(self.view["repo"].base, repo_name)
     self.g = Gittle.init(repopath, bare=False)
     self.g.commit("name", "email", "initial commit")
     self.view["repo"].text = repo_name
     console.hud_alert("Repo {} created".format(repo_name))
     self.did_select_repo(self.view["repo"])
Example #5
0
 def init_repo_if_empty(self, repo_name):
     repopath = os.path.join(self.view['repo'].base, repo_name)
     self.g = Gittle.init(repopath, bare=False)
     self.g.commit('name', 'email', 'initial commit')
     self.view['repo'].text = repo_name
     console.hud_alert('Repo {} created'.format(repo_name))
     self.did_select_repo(self.view['repo'])
Example #6
0
 def init_repo_if_empty(self,repo_name,gitpath):
     if not os.path.exists(gitpath):
         self.g= Gittle.init(gitpath,bare=False )
         self.g.commit('name','email','initial commit')
         self.view['repo'].text=repo_name
         console.hud_alert('Repo {} created'.format(repo_name))
         self.refresh()
Example #7
0
 def init(path):
     try:
         repo = Gittle.init(path)
         return repo
     except:
         AgentGitHandler.log.exception(
             "Initializing local repo at %r failed" % path)
         raise Exception("Initializing local repo at %r failed" % path)
Example #8
0
    def __init__(self, path):
        try:
            self.gittle = Gittle(path)
        except NotGitRepository:
            self.gittle = Gittle.init(path)

        # Dulwich repo
        self.repo = self.gittle.repo

        self.path = path
Example #9
0
    def __init__(self, path):
        try:
            self.gittle = Gittle(path)
        except NotGitRepository:
            self.gittle = Gittle.init(path)

        # Dulwich repo
        self.repo = self.gittle.repo

        self.path = path
Example #10
0
def push_directory_to_repo(directory, github_repo):
    auth = FixedGittleAuth(pkey=open(settings.GITHUB_PRIVATE_KEY))
    repo = Gittle.init(directory, auth=auth)

    files = []
    with work_in(directory):
        for root, dirnames, filenames in os.walk("."):
            # remove the leading './'
            root = root[2:]
            # skip .git directories
            if ".git" in dirnames:
                dirnames.remove(".git")

            for f in filenames:
                path = os.path.join(root, f)
                files.append(str(path))

    repo.commit(name="bakehouse", message="Hello world", files=files)
    repo.push(github_repo.ssh_url, branch_name="master")
Example #11
0
def GitUpload(file, Name, Email, Password, Repository, Message="Some uploads"):

    origin_uris = Repository
    if not origin_uris.startswith(Name):
        origin_uris = Name + "/" + origin_uris
    if not origin_uris.startswith("https://github.com/"):
        origin_uris = "https://github.com/" + origin_uris
    if not origin_uris.endswith(".git"):
        origin_uris = origin_uris + ".git"

    path = os.getcwd()

    # Gittle.clone() 会将当前目录下的文件下载到本地,并初始化git工作路径,上传文件正常
    # repo = Gittle.clone("https://github.com/fengfeng0918/gittle.git", path)
    # Gittle.init() 初始化git工作路径,并没有将远程仓库信息拉到本地,上传(push)文件时会将远程库清空
    # repo = Gittle.init(path,origin_uri="https://github.com/fengfeng0918/gittle.git")

    # git init  以下流程正常!!!
    if not os.path.exists(".git"):
        local_repo = Gittle.init(path)
        # local_repo = Gittle.clone(origin_uris,path)
        bares = False  #不会删除远端,重写本地
    else:
        local_repo = Repo(path)
        bares = True  # 不会删除远端,不重写本地

    repo = Gittle(local_repo, origin_uris)
    repo.fetch(bare=bares)

    # Stage file
    if not isinstance(file, list):
        file = [file]
    repo.stage(file)

    # Commiting
    repo.commit(name=Name, email=Email, message=Message, files=file)

    # add remote
    repo.add_remote('origin', origin_uris)

    # Push
    repo.auth(username=Name, password=Password)  # Auth for pushing
    repo.push()
Example #12
0
# License, Version 2.0.  See the COPYING file for further details.

import os
from gittle import Gittle
from tempfile import mkdtemp

path = mkdtemp()
fn = 'test.txt'
filename = os.path.join(path, fn)

name = 'Samy Pessé'
email = '*****@*****.**'
message = "C'est beau là bas"


def create_file():
    fd = open(filename, 'w+')
    fd.write('blabla\n BOOM BOOM\n à la montagne')
    fd.close()


repo = Gittle.init(path)
create_file()

repo.stage(fn)
repo.commit(name=name, email=email, message=message)

print('COMMIT_INFO =', repo.commit_info())

print('PATH =', path)
Example #13
0
 def init(self, repoPath):
 	self.repo = Gittle.init(repoPath)
 	print("Created Repo")
Example #14
0
# -*- coding: utf8 -*-

import os
from gittle import Gittle
from tempfile import mkdtemp

path = mkdtemp()
fn = 'test.txt'
filename = os.path.join(path, fn)

name = 'Samy Pessé'
email = '*****@*****.**'
message = "C'est beau là bas"


def create_file():
    fd = open(filename, 'w+')
    fd.write('blabla\n BOOM BOOM\n à la montagne')
    fd.close()

repo = Gittle.init(path)
create_file()

repo.stage(fn)
repo.commit(name=name, email=email, message=message)


print('COMMIT_INFO =', repo.commit_info())

print('PATH =', path)
Example #15
0
File: git.py Project: zx110101/00
def git_init(args):
    if len(args) == 1:
        Gittle.init(args[0])
    else:
        print(command_help['init'])
Example #16
0
		def git_init(args):
			if len(args) == 1:
				Gittle.init(args[0])
			else:
				print command_help['init']
Example #17
0
print repos.name
print repos.get_commits()[0].sha



repo_path = 'data'
repo_url = 'git://github.com/rhocode/axis.git'




try:
	repo = Gittle.clone(repo_url, repo_path)
except OSError:
	repo = Gittle.init(repo_path)

repo.switch_branch(b'gh-pages')

repo.pull()

# client, host_path = get_transport_and_path("https://github.com/rhocode/axis.git")
# r = Repo.init("test", mkdir=True)
# remote_refs = client.fetch(host_path, r,
#     determine_wants=r.object_store.determine_wants_all,
#     progress=sys.stdout.write)

# branches = client.fetch(host_path, r)

# r["HEAD"] = remote_refs["HEAD"]