A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/GitoxideLabs/gitoxide/commit/a75b4a2bc0cc602da336421ebcfda11dd36545b7 below:

branch_remote_ref_name()` won't fail on short names… · GitoxideLabs/gitoxide@a75b4a2 · GitHub

File tree Expand file treeCollapse file tree 2 files changed

+28

-14

lines changed

Filter options

Expand file treeCollapse file tree 2 files changed

+28

-14

lines changed Original file line number Diff line number Diff line change

@@ -52,7 +52,16 @@ impl crate::Repository {

52 52

self.config

53 53

.resolved

54 54

.string_by("branch", Some(short_name), Branch::MERGE.name)

55 -

.map(|name| crate::config::tree::branch::Merge::try_into_fullrefname(name).map_err(Into::into))

55 +

.map(|name| {

56 +

if name.starts_with(b"refs/") {

57 +

crate::config::tree::branch::Merge::try_into_fullrefname(name)

58 +

} else {

59 +

gix_ref::Category::LocalBranch

60 +

.to_full_name(name.as_ref())

61 +

.map(Cow::Owned)

62 +

}

63 +

.map_err(Into::into)

64 +

})

56 65

}

57 66

remote::Direction::Push => {

58 67

let remote = match self.branch_remote(name.shorten(), direction)? {

Original file line number Diff line number Diff line change

@@ -131,15 +131,21 @@ mod branch_remote {

131 131

.as_ref(),

132 132

"remote_repo"

133 133

);

134 +

assert_eq!(

135 +

repo.branch_remote_name("broken", direction)

136 +

.expect("Remote name exists")

137 +

.as_ref(),

138 +

"remote_repo"

139 +

);

134 140

}

135 141 136 -

let merge_branch_invalid_msg = "The configured name of the remote ref to merge wasn't valid";

137 142

assert_eq!(

138 143

repo.branch_remote_ref_name("refs/heads/broken".try_into()?, remote::Direction::Fetch)

139 144

.expect("Remote Merge ref exists")

140 -

.unwrap_err()

141 -

.to_string(),

142 -

merge_branch_invalid_msg

145 +

.expect("merge ref is turned into a full-name")

146 +

.as_bstr(),

147 +

"refs/heads/not_a_valid_merge_ref",

148 +

"short names are simply turned into branch names - this doesn't always work, but sometimes."

143 149

);

144 150

assert!(repo

145 151

.branch_remote_ref_name("refs/heads/missing".try_into()?, remote::Direction::Fetch)

@@ -152,11 +158,11 @@ mod branch_remote {

152 158

}

153 159

assert_eq!(

154 160

repo.branch_remote_tracking_ref_name("refs/heads/broken".try_into()?, remote::Direction::Fetch)

155 -

.expect("err")

156 -

.unwrap_err()

157 -

.to_string(),

158 -

"Could not get the remote reference to translate into the local tracking branch",

159 -

"the merge ref is broken, hence there can't be a tracking ref",

161 +

.expect("no error")

162 +

.expect("valid result")

163 +

.as_bstr(),

164 +

"refs/remotes/remote_repo/not_a_valid_merge_ref",

165 +

"the merge ref is broken, but we turned it into a full ref name from which everything else was derived",

160 166

);

161 167 162 168

Ok(())

@@ -219,10 +225,9 @@ mod branch_remote {

219 225

);

220 226

}

221 227 222 -

assert_eq!(

223 -

repo.branch_remote_tracking_ref_name("refs/heads/broken".try_into()?, remote::Direction::Push).expect("has err").unwrap_err().to_string(),

224 -

"Could not get the remote reference to translate into the local tracking branch",

225 -

"push.default = simple, hence we need to verify the merge-branch is the same as us, but retrieving it fails",

228 +

assert!(

229 +

repo.branch_remote_tracking_ref_name("refs/heads/broken".try_into()?, remote::Direction::Push).is_none(),

230 +

"push.default = simple, hence we need to verify the merge-branch is the same as us, and retrieving it succeeds due to auto-fullnamification but then it doesn't match",

226 231

);

227 232 228 233

Ok(())

You can’t perform that action at this time.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4