def empty_repository() -> Repository:
    from uuid import uuid4
    directory_name = str(uuid4())

    os.mkdir(directory_name)
    repository = Repository.build(directory_name, create_repository=True)
    yield repository

    shutil.rmtree(directory_name)
示例#2
0
def main(unused: List[str]):
    del unused
    repository = Repository(FLAGS.repository)

    cache = Cache(FLAGS.cache, FLAGS.override)
    cache.update(repository)
    cache.dump()

    generate_images(cache, FLAGS.image)
    get_badges(cache)
 def walk_commit(self, repository: Repository):
     visited = set(
         repository.get_commit(visited) for visited in self.visited)
     search = set([repository.last_commit]) - visited
     while search:
         commit = search.pop()
         search |= set(commit.parents) - visited
         visited.add(commit)
         if (MERGE_STRING not in commit.message
                 and README_STRING not in commit.message):
             yield commit
示例#4
0
class GitHandler:
    def __init__(self, git_path: Path):
        self.repo = Repository(path=str(git_path))

    def is_dirty(self) -> bool:
        status = self.repo.status()
        return status.modified or status.added or status.deleted or status.renamed or status.untracked

    def print_dirty(self) -> None:
        status = self.repo.status()
        for m in status.modified:
            print(f"{m} --- Modified")
        for a in status.added:
            print(f"{a} --- Added")
        for d in status.deleted:
            print(f"{d} --- Deleted ")
        for r in status.renamed:
            print(f"{r} --- Renamed")
        for u in status.untracked:
            print(f"{u} --- Untracked")

    def push_version(self, ver: VersionHandler) -> None:
        self.repo.commit(message=f"Publish New Package Version: {str(ver)}",
                         add_files=True)
        self.repo.push()
def repository_with_file() -> Repository:
    from uuid import uuid4

    directory_name = str(uuid4())
    os.mkdir(directory_name)

    file_name = create_random_file_in_directory(directory_name)

    repository = Repository.build(directory_name, create_repository=True)

    yield repository, file_name

    shutil.rmtree(directory_name)
def repository_with_commits() -> Repository:
    from uuid import uuid4

    directory_name = str(uuid4())
    file_name = str(randint(0, 100000))

    os.mkdir(directory_name)
    open(os.path.join(directory_name, file_name), 'w').close()
    repository = Repository.build(directory_name, create_repository=True)
    repository.add_files(all_files=True)
    repository.commit('test')

    yield repository

    shutil.rmtree(directory_name)
示例#7
0
文件: main.py 项目: William-LP/gitart
                         ['x', 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0],                                          
                         ['x', 0, 0, 0, 1, 0, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 0, 1, 1, 1, 0, 1, 0, 1, 0, 1, 1, 1, 0, 1, 1, 0, 0, 0, 1, 0, 0, 0],
                           [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ,0, 0, 0, 0, 0, 0, 0]              
])

# create a list by column (github calendar format)
flatten_matrix=git_calendar.flatten('F')
# remove the 'x' that represent the days out of current year
calendar = np.delete(flatten_matrix, np.where(flatten_matrix == 'x'))
# get the day of the year : 1 for January 1st
day_of_year = datetime.now().timetuple().tm_yday 

# if today one need to mark the calendar with a pixel :
if calendar[day_of_year] == 1 :
        for i in range(1,10):
        # get a random word 
        a_random_word = RandomWords().get_random_word()
        # write that word to a file  
        f = open("hello_world.txt", "w")
        f.write(a_random_word)
        f.close()
        # set this directory as a repo
        repository = Repository('.')
        # stage the whole repo for next commit because adding only updated file doesn't work
        repository.add_files('.')
        # commit
        repository.commit(a_random_word)
        # push
        repository.push()

def create_random_commit(repository: Repository) -> Commit:
    file_name = create_random_file_in_directory(repository.path)

    repository.add_files([file_name])
    repository.commit(file_name + "" + str(randint(0, 100000)))
    return repository.last_commit
示例#9
0
 def __init__(self, git_path: Path):
     self.repo = Repository(path=str(git_path))