Add pull request capability

Change-Id: Ib54054cc9b32930764cc2110203742c3948f9ea3
diff --git a/server/git/git.go b/server/git/git.go
index fdcd467..dc3885f 100644
--- a/server/git/git.go
+++ b/server/git/git.go
@@ -52,6 +52,14 @@
 	SetConfig(ctx context.Context, key, value string) error
 	GetUserConfig(ctx context.Context) (*UserConfig, error)
 	SetUserConfig(ctx context.Context, config UserConfig) error
+
+	// Pull Request operations
+	CreatePullRequest(ctx context.Context, options PullRequestOptions) (*PullRequest, error)
+	GetPullRequest(ctx context.Context, id string) (*PullRequest, error)
+	ListPullRequests(ctx context.Context, options ListPullRequestOptions) ([]PullRequest, error)
+	UpdatePullRequest(ctx context.Context, id string, options PullRequestOptions) (*PullRequest, error)
+	ClosePullRequest(ctx context.Context, id string) error
+	MergePullRequest(ctx context.Context, id string, options MergePullRequestOptions) error
 }
 
 // Status represents the current state of the repository
@@ -178,14 +186,16 @@
 
 // Git implementation using os/exec to call git commands
 type Git struct {
-	repoPath string
-	config   GitConfig
+	repoPath   string
+	config     GitConfig
+	prProvider PullRequestProvider
 }
 
 // GitConfig holds configuration for Git operations
 type GitConfig struct {
-	Timeout time.Duration
-	Env     map[string]string
+	Timeout             time.Duration
+	Env                 map[string]string
+	PullRequestProvider PullRequestProvider
 }
 
 // NewGit creates a new Git instance
@@ -195,8 +205,9 @@
 	}
 
 	return &Git{
-		repoPath: repoPath,
-		config:   config,
+		repoPath:   repoPath,
+		config:     config,
+		prProvider: config.PullRequestProvider,
 	}
 }
 
@@ -208,6 +219,12 @@
 	})
 }
 
+// NewGitWithPullRequests creates a Git instance with pull request capabilities
+func NewGitWithPullRequests(repoPath string, config GitConfig, prProvider PullRequestProvider) GitInterface {
+	config.PullRequestProvider = prProvider
+	return NewGit(repoPath, config)
+}
+
 // Ensure Git implements GitInterface
 var _ GitInterface = (*Git)(nil)
 
@@ -567,6 +584,56 @@
 	return g.SetConfig(ctx, "user.email", config.Email)
 }
 
+// Pull Request operations
+
+// CreatePullRequest creates a new pull request
+func (g *Git) CreatePullRequest(ctx context.Context, options PullRequestOptions) (*PullRequest, error) {
+	if g.prProvider == nil {
+		return nil, &GitError{Command: "CreatePullRequest", Output: "no pull request provider configured"}
+	}
+	return g.prProvider.CreatePullRequest(ctx, options)
+}
+
+// GetPullRequest retrieves a pull request by ID
+func (g *Git) GetPullRequest(ctx context.Context, id string) (*PullRequest, error) {
+	if g.prProvider == nil {
+		return nil, &GitError{Command: "GetPullRequest", Output: "no pull request provider configured"}
+	}
+	return g.prProvider.GetPullRequest(ctx, id)
+}
+
+// ListPullRequests lists pull requests
+func (g *Git) ListPullRequests(ctx context.Context, options ListPullRequestOptions) ([]PullRequest, error) {
+	if g.prProvider == nil {
+		return nil, &GitError{Command: "ListPullRequests", Output: "no pull request provider configured"}
+	}
+	return g.prProvider.ListPullRequests(ctx, options)
+}
+
+// UpdatePullRequest updates a pull request
+func (g *Git) UpdatePullRequest(ctx context.Context, id string, options PullRequestOptions) (*PullRequest, error) {
+	if g.prProvider == nil {
+		return nil, &GitError{Command: "UpdatePullRequest", Output: "no pull request provider configured"}
+	}
+	return g.prProvider.UpdatePullRequest(ctx, id, options)
+}
+
+// ClosePullRequest closes a pull request
+func (g *Git) ClosePullRequest(ctx context.Context, id string) error {
+	if g.prProvider == nil {
+		return &GitError{Command: "ClosePullRequest", Output: "no pull request provider configured"}
+	}
+	return g.prProvider.ClosePullRequest(ctx, id)
+}
+
+// MergePullRequest merges a pull request
+func (g *Git) MergePullRequest(ctx context.Context, id string, options MergePullRequestOptions) error {
+	if g.prProvider == nil {
+		return &GitError{Command: "MergePullRequest", Output: "no pull request provider configured"}
+	}
+	return g.prProvider.MergePullRequest(ctx, id, options)
+}
+
 // Helper methods
 
 func (g *Git) runCommand(cmd *exec.Cmd, command string) error {
@@ -795,3 +862,77 @@
 
 	return remotes, nil
 }
+
+// PullRequest represents a pull request or merge request
+type PullRequest struct {
+	ID          string
+	Number      int
+	Title       string
+	Description string
+	State       string // "open", "closed", "merged"
+	Author      Author
+	CreatedAt   time.Time
+	UpdatedAt   time.Time
+	BaseBranch  string
+	HeadBranch  string
+	BaseRepo    string
+	HeadRepo    string
+	Labels      []string
+	Assignees   []Author
+	Reviewers   []Author
+	Commits     []Commit
+	Comments    []PullRequestComment
+}
+
+// PullRequestComment represents a comment on a pull request
+type PullRequestComment struct {
+	ID        string
+	Author    Author
+	Content   string
+	CreatedAt time.Time
+	UpdatedAt time.Time
+	Path      string
+	Line      int
+}
+
+// PullRequestOptions defines options for creating/updating pull requests
+type PullRequestOptions struct {
+	Title       string
+	Description string
+	BaseBranch  string
+	HeadBranch  string
+	BaseRepo    string
+	HeadRepo    string
+	Labels      []string
+	Assignees   []string
+	Reviewers   []string
+	Draft       bool
+}
+
+// ListPullRequestOptions defines options for listing pull requests
+type ListPullRequestOptions struct {
+	State      string // "open", "closed", "all"
+	Author     string
+	Assignee   string
+	BaseBranch string
+	HeadBranch string
+	Labels     []string
+	Limit      int
+}
+
+// MergePullRequestOptions defines options for merging pull requests
+type MergePullRequestOptions struct {
+	MergeMethod string // "merge", "squash", "rebase"
+	CommitTitle string
+	CommitMsg   string
+}
+
+// PullRequestProvider defines the interface for pull request operations
+type PullRequestProvider interface {
+	CreatePullRequest(ctx context.Context, options PullRequestOptions) (*PullRequest, error)
+	GetPullRequest(ctx context.Context, id string) (*PullRequest, error)
+	ListPullRequests(ctx context.Context, options ListPullRequestOptions) ([]PullRequest, error)
+	UpdatePullRequest(ctx context.Context, id string, options PullRequestOptions) (*PullRequest, error)
+	ClosePullRequest(ctx context.Context, id string) error
+	MergePullRequest(ctx context.Context, id string, options MergePullRequestOptions) error
+}