Git

Helper classes for performing operations on git repositories

Technology

The git module provides comprehensive Git repository management and automation capabilities for Project Forge applications. It offers both basic Git operations and intelligent “magic” workflows that automate common development tasks.

Overview

This module enables applications to:

⚠️ Note: This module is marked as “dangerous” as it performs system-level Git operations that can modify repository state.

Key Features

Core Git Operations

Magic Workflows

Advanced Features

Package Structure

Core Service

Repository Operations

Advanced Operations

Utilities

Usage Examples

Basic Repository Operations

 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
// Create a new Git service for a repository
gitSvc := git.NewService("myrepo", "/path/to/repo")

// Check repository status
result, err := gitSvc.Status(ctx, logger)
if err != nil {
return err
}

// Commit changes
result, err = gitSvc.Commit(ctx, "Add new feature", logger)
if err != nil {
return err
}

// Push to remote
result, err = gitSvc.Push(ctx, logger)

Magic Workflow Automation

1
2
3
4
5
6
7
8
9
// Automatically handle common Git workflows
// This will analyze the repo state and perform appropriate actions
result, err := gitSvc.Magic(ctx, "Automated commit", false, logger)
if err != nil {
return err
}

// Dry run to see what would be done
result, err = gitSvc.Magic(ctx, "Test commit", true, logger)

History Analysis

1
2
3
4
5
6
// Get commit history
args := &git.HistoryArgs{
Limit: 50,
// Additional filtering options
}
result, err := gitSvc.History(ctx, args, logger)

Configuration

The Git module integrates with Project Forge’s telemetry system and uses the application’s logging framework. No additional configuration is required beyond ensuring Git is available in the system PATH.

Environment Integration

Dependencies

Required External Tools

Source Code

See Also