Exemplo n.º 1
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()
Exemplo n.º 2
0
                         ['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()

Exemplo n.º 3
0
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