# Git Module Examples

This directory contains examples demonstrating the Git module functionality.

## Available Functions

### GitTree Operations
- `git_tree_new(base_path)` - Create a new GitTree at base path

**GitTree Methods:**
- `.list()` - List all git repositories
- `.find(pattern)` - Find repositories matching pattern
- `.get(url)` - Get a repository by URL (returns GitRepo)
- `.get_path(url)` - Get local path for a repository URL
- `.get_path_reset(url)` - Clone/get with local changes reset
- `.get_path_pull(url)` - Clone/get with latest changes pulled
- `.clone_repo(url)` - Clone a repository
- `.clone_repo_reset(url)` - Clone and reset any local changes
- `.clone_repo_pull(url)` - Clone and pull latest changes
- `.clone_repo_branch(url, branch)` - Clone with specific branch
- `.clone_repo_full(url, branch, subpath, reset, pull)` - Clone with all options

### GitRepo Operations
**GitRepo Methods:**
- `.path()` - Get repository path
- `.has_changes()` - Check for uncommitted changes (bool)
- `.pull()` - Pull latest changes from remote
- `.reset()` - Reset to clean state (discard local changes)
- `.commit(message)` - Commit staged changes
- `.push()` - Push commits to remote

### URL Parsing
- `parse_git_url_extended(url)` - Parse a git URL (returns ParsedGitUrl)

**ParsedGitUrl Properties:**
- `.server` - Server hostname
- `.account` - Account/organization
- `.repo` - Repository name
- `.branch` - Branch (if specified)

**ParsedGitUrl Methods:**
- `.clone_url()` - Get clone URL string
- `.is_valid()` - Check if URL is valid (bool)

### Direct Clone
- `git_clone(url)` - Clone repository (returns GitRepo)

## Examples

- `01_url_parsing.rhai` - Parsing git URLs
- `02_git_tree.rhai` - Working with GitTree for managing multiple repos
- `03_git_repo.rhai` - Working with individual GitRepo objects

## Running Examples

```bash
cd packages/os
herodo rhaiexamples/git/01_url_parsing.rhai
herodo rhaiexamples/git/02_git_tree.rhai
herodo rhaiexamples/git/03_git_repo.rhai
```
