Add booleans for displaying push/merge buttons

*** WIP ***
Still need to add some tests for this.
Committing so we can work on the frontend
This commit is contained in:
mike cullerton 2022-03-02 12:03:08 -05:00
parent 07e13584e7
commit cb65a7dc41
3 changed files with 9 additions and 1 deletions

View File

@ -84,6 +84,8 @@ GIT_REMOTE_SERVER = environ.get('GIT_REMOTE_SERVER', None) # example: 'github.c
GIT_REMOTE_PATH = environ.get('GIT_REMOTE_PATH', None) # example: 'sartography/crconnect-workflow-specs
GIT_BRANCH = environ.get('GIT_BRANCH', None) # example: 'main'
GIT_MERGE_BRANCH = environ.get('GIT_MERGE_BRANCH', None) # Example: 'staging'
GIT_DISPLAY_PUSH = environ.get('GIT_DISPLAY_PUSH', False)
GIT_DISPLAY_MERGE = environ.get('GIT_DISPLAY_MERGE', False)
# Email configuration
DEFAULT_SENDER = 'crconnect2@virginia.edu'

View File

@ -11,6 +11,8 @@ class GitRepo(object):
instance.merge_branch = app.config['GIT_MERGE_BRANCH']
instance.changes = [item.a_path for item in repo.index.diff(None)]
instance.untracked = repo.untracked_files
instance.display_push = repo.display_push
instance.display_merge = repo.display_merge
return instance
@ -18,7 +20,7 @@ class GitRepo(object):
class GitRepoSchema(ma.Schema):
class Meta:
model = GitRepo
fields = ["directory", "branch", "merge_branch", "changes", "untracked"]
fields = ["directory", "branch", "merge_branch", "changes", "untracked", "display_push", "display_merge"]
class GitCommit(object):

View File

@ -45,6 +45,8 @@ class GitService(object):
remote_path = app.config['GIT_REMOTE_PATH']
git_branch = app.config['GIT_BRANCH']
directory = app.config['SYNC_FILE_ROOT']
display_push = app.config['GIT_DISPLAY_PUSH']
display_merge = app.config['GIT_DISPLAY_MERGE']
try:
repo = Repo(directory)
@ -79,6 +81,8 @@ class GitService(object):
remote_ref = repo.remotes.origin.refs[f'{git_branch}']
repo.active_branch.set_tracking_branch(remote_ref)
repo.display_push = display_push
repo.display_merge = display_merge
return repo
def _get_repo(self):