...
This commit is contained in:
		@@ -183,36 +183,33 @@ Commits staged changes.
 | 
			
		||||
Pushes committed changes to the remote.
 | 
			
		||||
 | 
			
		||||
- **Description**: Performs `git push` to the default remote and branch.
 | 
			
		||||
- **Returns**: `GitRepo` - The same `GitRepo` object for chaining. Halts on error (e.g., network issues, push rejected).
 | 
			
		||||
- **Rhai Example** (assuming `app_repo` is a `GitRepo` object with committed changes):
 | 
			
		||||
    ```rhai
 | 
			
		||||
    print(`Pushing changes for ${app_repo.path()}...`);
 | 
			
		||||
    app_repo.push(); // Halts on error
 | 
			
		||||
    print("Push successful.");
 | 
			
		||||
    ```
 | 
			
		||||
- **Returns**: `GitRepo`
 | 
			
		||||
 | 
			
		||||
```rhai
 | 
			
		||||
print(`Pushing changes for ${app_repo.path()}...`);
 | 
			
		||||
app_repo.push(); // Halts on error
 | 
			
		||||
print("Push successful.");
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
## Chaining Operations
 | 
			
		||||
 | 
			
		||||
`GitRepo` methods like `pull`, `reset`, `commit`, and `push` return the `GitRepo` object, allowing for chained operations. If any operation in the chain fails, script execution halts.
 | 
			
		||||
```rhai
 | 
			
		||||
let git_tree = git_tree_new("./my_projects");
 | 
			
		||||
// Assumes "my_writable_app" exists and you have write access.
 | 
			
		||||
// get() will halt if not found.
 | 
			
		||||
let app_repo = git_tree.get("my_writable_app");
 | 
			
		||||
print(`Performing chained operations on ${app_repo.path()}`);
 | 
			
		||||
 | 
			
		||||
- **Rhai Example**:
 | 
			
		||||
    ```rhai
 | 
			
		||||
    let git_tree = git_tree_new("./my_projects");
 | 
			
		||||
    // Assumes "my_writable_app" exists and you have write access.
 | 
			
		||||
    // get() will halt if not found.
 | 
			
		||||
    let app_repo = git_tree.get("my_writable_app");
 | 
			
		||||
    print(`Performing chained operations on ${app_repo.path()}`);
 | 
			
		||||
// This example demonstrates a common workflow.
 | 
			
		||||
// Ensure the repo state is suitable (e.g., changes exist for commit/push).
 | 
			
		||||
app_repo.pull()
 | 
			
		||||
        .commit("Rhai: Chained operations - automated update") // Commits if pull results in changes or local changes existed and were staged.
 | 
			
		||||
        .push();
 | 
			
		||||
print("Chained pull, commit, and push reported successful.");
 | 
			
		||||
 | 
			
		||||
    // This example demonstrates a common workflow.
 | 
			
		||||
    // Ensure the repo state is suitable (e.g., changes exist for commit/push).
 | 
			
		||||
    app_repo.pull()
 | 
			
		||||
            .commit("Rhai: Chained operations - automated update") // Commits if pull results in changes or local changes existed and were staged.
 | 
			
		||||
            .push();
 | 
			
		||||
    print("Chained pull, commit, and push reported successful.");
 | 
			
		||||
 | 
			
		||||
    // Alternative:
 | 
			
		||||
    // app_repo.pull();
 | 
			
		||||
    // if app_repo.has_changes() {
 | 
			
		||||
    //     app_repo.commit("Updates").push();
 | 
			
		||||
    // }
 | 
			
		||||
    ```
 | 
			
		||||
// Alternative:
 | 
			
		||||
// app_repo.pull();
 | 
			
		||||
// if app_repo.has_changes() {
 | 
			
		||||
//     app_repo.commit("Updates").push();
 | 
			
		||||
// }
 | 
			
		||||
```
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user