mirror of
https://github.com/Dictionarry-Hub/profilarr.git
synced 2026-01-22 10:51:02 +01:00
feature: merge conflict detection and resolution (#6)
- pulls now correctly identify merge conflicts and enter a merge state - user resolves each file individually - commit resolve merge state - allows users to keep custom changes and pull in updates - improve commit message component - seperated commit / add functionality
This commit is contained in:
@@ -1,5 +1,3 @@
|
||||
# git/operations/operations.py
|
||||
|
||||
import git
|
||||
from .stage import stage_files
|
||||
from .commit import commit_changes
|
||||
@@ -7,19 +5,50 @@ from .push import push_changes
|
||||
from .revert import revert_file, revert_all
|
||||
from .delete import delete_file
|
||||
from .pull import pull_branch
|
||||
from .unstage import unstage_files
|
||||
from .merge import abort_merge, finalize_merge
|
||||
from .resolve import resolve_conflicts
|
||||
import os
|
||||
import logging
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class GitOperations:
|
||||
|
||||
def __init__(self, repo_path):
|
||||
self.repo_path = repo_path
|
||||
self.configure_git()
|
||||
|
||||
def configure_git(self):
|
||||
try:
|
||||
repo = git.Repo(self.repo_path)
|
||||
# Get user info from env variables
|
||||
git_name = os.environ.get('GITHUB_USER_NAME')
|
||||
git_email = os.environ.get('GITHUB_USER_EMAIL')
|
||||
|
||||
logger.debug(f"Git config - Name: {git_name}, Email: {git_email}"
|
||||
) # Add this
|
||||
|
||||
if git_name and git_email:
|
||||
with repo.config_writer() as config:
|
||||
config.set_value('user', 'name', git_name)
|
||||
config.set_value('user', 'email', git_email)
|
||||
logger.debug("Git identity configured successfully")
|
||||
except Exception as e:
|
||||
logger.error(f"Error configuring git user: {str(e)}")
|
||||
|
||||
def stage(self, files):
|
||||
return stage_files(self.repo_path, files)
|
||||
|
||||
def unstage(self, files):
|
||||
return unstage_files(self.repo_path, files)
|
||||
|
||||
def commit(self, files, message):
|
||||
return commit_changes(self.repo_path, files, message)
|
||||
|
||||
def push(self, files, message):
|
||||
return push_changes(self.repo_path, files, message)
|
||||
def push(self):
|
||||
return push_changes(self.repo_path)
|
||||
|
||||
def revert(self, file_path):
|
||||
return revert_file(self.repo_path, file_path)
|
||||
@@ -31,4 +60,15 @@ class GitOperations:
|
||||
return delete_file(self.repo_path, file_path)
|
||||
|
||||
def pull(self, branch_name):
|
||||
return pull_branch(self.repo_path, branch_name)
|
||||
return pull_branch(self.repo_path, branch_name)
|
||||
|
||||
def finalize_merge(self):
|
||||
repo = git.Repo(self.repo_path)
|
||||
return finalize_merge(repo)
|
||||
|
||||
def abort_merge(self):
|
||||
return abort_merge(self.repo_path)
|
||||
|
||||
def resolve(self, resolutions):
|
||||
repo = git.Repo(self.repo_path)
|
||||
return resolve_conflicts(repo, resolutions)
|
||||
|
||||
Reference in New Issue
Block a user