2022-01-28 16:11:36 -05:00
|
|
|
from crc import app, ma
|
|
|
|
|
|
|
|
|
|
|
|
class GitRepo(object):
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
def from_repo(cls, repo):
|
|
|
|
instance = cls()
|
|
|
|
instance.directory = repo.working_dir
|
2022-02-01 10:49:35 -05:00
|
|
|
instance.branch = repo.active_branch.name
|
2022-01-28 16:11:36 -05:00
|
|
|
instance.merge_branch = app.config['GIT_MERGE_BRANCH']
|
2022-02-01 10:49:35 -05:00
|
|
|
instance.changes = [item.a_path for item in repo.index.diff(None)]
|
|
|
|
instance.untracked = repo.untracked_files
|
2022-03-02 12:03:08 -05:00
|
|
|
instance.display_push = repo.display_push
|
|
|
|
instance.display_merge = repo.display_merge
|
2022-02-01 10:49:35 -05:00
|
|
|
|
|
|
|
return instance
|
2022-01-28 16:11:36 -05:00
|
|
|
|
|
|
|
|
|
|
|
class GitRepoSchema(ma.Schema):
|
|
|
|
class Meta:
|
|
|
|
model = GitRepo
|
2022-03-02 12:03:08 -05:00
|
|
|
fields = ["directory", "branch", "merge_branch", "changes", "untracked", "display_push", "display_merge"]
|
2022-01-28 16:11:36 -05:00
|
|
|
|
|
|
|
|
2022-02-02 12:51:14 -05:00
|
|
|
class GitCommit(object):
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
2022-01-28 16:11:36 -05:00
|
|
|
class GitCommitSchema(ma.Schema):
|
|
|
|
class Meta:
|
|
|
|
model = GitCommit
|
|
|
|
fields = ["message", "files"]
|