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.status = repo.index.diff(repo.head.commit)
|
2022-01-28 16:11:36 -05:00
|
|
|
# instance.user =
|
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
|
|
|
|
|
|
|
|
return instance
|
2022-01-28 16:11:36 -05:00
|
|
|
|
|
|
|
|
|
|
|
class GitCommit(object):
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
class GitRepoSchema(ma.Schema):
|
|
|
|
class Meta:
|
|
|
|
model = GitRepo
|
2022-02-01 10:49:35 -05:00
|
|
|
fields = ["directory", "branch", "merge_branch", "status", "changes", "untracked"]
|
2022-01-28 16:11:36 -05:00
|
|
|
|
|
|
|
|
|
|
|
class GitCommitSchema(ma.Schema):
|
|
|
|
class Meta:
|
|
|
|
model = GitCommit
|
|
|
|
fields = ["message", "files"]
|