예제 #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()
예제 #2
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()