1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
//! Git Remote Operations
//!
//! Remote repository operations including push functionality with dry-run support.
use IsTerminal;
use Command;
use Duration;
use ProgressBar;
use ProgressDrawTarget;
use crate;
/// Pushes committed changes to the remote repository.
///
/// This function pushes to the remote repository with optional additional arguments.
/// It provides feedback on the operation's success or failure.
///
/// Note: Uses the git command to properly handle authentication (SSH keys, credentials, etc.)
/// rather than git2's push API which requires complex callback setup.
///
/// # Arguments
/// * `args` - Additional arguments to pass to the git push command (e.g., `--force`, `origin main`)
/// * `verbose` - Whether to print verbose output during the operation
/// * `dry_run` - If true, only show what would be pushed without actually pushing
///
/// # Errors
/// * If the git push command fails
/// * If not in a git repository
/// * If no remote repository is configured
/// * If authentication fails
///
/// # Panics
/// * If the internal git push thread panics (should not happen in normal use)
///
/// # Examples
///
/// ```no_run
/// use rona::git::remote::git_push;
///
/// // Basic push
/// git_push(&vec![], false, false)?;
///
/// // Push with force
/// git_push(&vec!["--force".to_string()], true, false)?;
///
/// // Push to specific remote and branch
/// git_push(&vec!["origin".to_string(), "main".to_string()], false, false)?;
///
/// // Dry run to preview the push
/// git_push(&vec![], false, true)?;
/// # Ok::<(), Box<dyn std::error::Error>>(())
/// ```
/// Handles the output of git commands, providing consistent error handling and success messaging.
///
/// This function processes the output of git commands and:
/// - Prints success messages when verbose mode is enabled
/// - Displays command output if present
/// - Formats and prints error messages with suggestions when commands fail
///
/// # Arguments
/// * `method_name` - The name of the git command being executed (e.g., "commit", "push")
/// * `output` - The `Output` struct containing the command's stdout, stderr, and status
/// * `verbose` - Whether to print verbose output during the operation
///
/// # Returns
/// * `Result<()>` - `Ok(())` if the command succeeded, `Err(RonaError)` if it failed
// Use the shared handle_output function from the parent module
use handle_output;