|
| 1 | +use crate::repository::{branch_remote_ref_name, branch_remote_tracking_ref_name}; |
1 | 2 | use crate::{remote, Reference};
|
| 3 | +use gix_ref::FullNameRef; |
| 4 | +use std::borrow::Cow; |
2 | 5 |
|
3 | 6 | /// Remotes
|
4 | 7 | impl<'repo> Reference<'repo> {
|
5 | 8 | /// Find the name of our remote for `direction` as configured in `branch.<name>.remote|pushRemote` respectively.
|
6 |
| - /// If `Some(<name>)` it can be used in [`Repository::find_remote(…)`][crate::Repository::find_remote()], or if `None` then |
7 |
| - /// [`Repository::remote_default_name()`][crate::Repository::remote_default_name()] could be used in its place. |
8 |
| - /// |
9 | 9 | /// Return `None` if no remote is configured.
|
10 | 10 | ///
|
11 |
| - /// # Note |
12 |
| - /// |
13 |
| - /// - it's recommended to use the [`remote(…)`][Self::remote()] method as it will configure the remote with additional |
14 |
| - /// information. |
15 |
| - /// - `branch.<name>.pushRemote` falls back to `branch.<name>.remote`. |
| 11 | + /// See also [`Repository::branch_remote_name()`](crate::Repository::branch_remote_name()) for more details. |
16 | 12 | pub fn remote_name(&self, direction: remote::Direction) -> Option<remote::Name<'repo>> {
|
17 | 13 | self.repo.branch_remote_name(self.name().shorten(), direction)
|
18 | 14 | }
|
19 | 15 |
|
20 |
| - /// Like [`branch_remote(…)`](crate::Repository::branch_remote()), but automatically provides the reference name |
21 |
| - /// for configuration lookup. |
| 16 | + /// Find the remote along with all configuration associated with it suitable for handling this reference. |
| 17 | + /// |
| 18 | + /// See also [`Repository::branch_remote()`](crate::Repository::branch_remote()) for more details. |
22 | 19 | pub fn remote(
|
23 | 20 | &self,
|
24 | 21 | direction: remote::Direction,
|
25 | 22 | ) -> Option<Result<crate::Remote<'repo>, remote::find::existing::Error>> {
|
26 | 23 | self.repo.branch_remote(self.name().shorten(), direction)
|
27 | 24 | }
|
| 25 | + |
| 26 | + /// Return the name of this reference on the remote side. |
| 27 | + /// |
| 28 | + /// See [`Repository::branch_remote_ref_name()`](crate::Repository::branch_remote_ref_name()) for details. |
| 29 | + #[doc(alias = "upstream", alias = "git2")] |
| 30 | + pub fn remote_ref_name( |
| 31 | + &self, |
| 32 | + direction: remote::Direction, |
| 33 | + ) -> Option<Result<Cow<'_, FullNameRef>, branch_remote_ref_name::Error>> { |
| 34 | + self.repo.branch_remote_ref_name(self.name(), direction) |
| 35 | + } |
| 36 | + |
| 37 | + /// Return the name of the reference that tracks this reference on the remote side. |
| 38 | + /// |
| 39 | + /// See [`Repository::branch_remote_tracking_ref_name()`](crate::Repository::branch_remote_tracking_ref_name()) for details. |
| 40 | + #[doc(alias = "upstream", alias = "git2")] |
| 41 | + pub fn remote_tracking_ref_name( |
| 42 | + &self, |
| 43 | + direction: remote::Direction, |
| 44 | + ) -> Option<Result<Cow<'_, FullNameRef>, branch_remote_tracking_ref_name::Error>> { |
| 45 | + self.repo.branch_remote_tracking_ref_name(self.name(), direction) |
| 46 | + } |
28 | 47 | }
|
0 commit comments