mirror of
https://github.com/msfjarvis/gitice.git
synced 2024-06-03 03:58:56 +05:30
Use upstream remote URL for the currently checked out branch
Signed-off-by: ATechnoHazard <amolele@gmail.com>
This commit is contained in:
parent
5fcba2926c
commit
444564a43d
26
src/main.rs
26
src/main.rs
|
@ -31,13 +31,25 @@ fn main() -> anyhow::Result<()> {
|
|||
|
||||
let head = repo.head()?;
|
||||
if let Some(head) = head.name() {
|
||||
repos.push(PersistableRepo {
|
||||
// Ideally we wanna do this, but it moves `dir`.
|
||||
// path: entry.path().to_string_lossy().strip_prefix(dir).unwrap().to_string(),
|
||||
path: entry.path().to_string_lossy().to_string(),
|
||||
remote_url: repo.remotes()?.get(0).unwrap_or("None").to_string(),
|
||||
head: head.to_string(),
|
||||
});
|
||||
if let Ok(upstream) = repo.branch_upstream_name(head) {
|
||||
if let Ok(remote) = repo.find_remote(
|
||||
// This is a rather ugly hack, but not sure how else to get the required name
|
||||
// doesn't seem to work with the full name such as `refs/remotes/origin/master`
|
||||
upstream
|
||||
.as_str()
|
||||
.unwrap_or("None")
|
||||
.split("/")
|
||||
.collect::<Vec<&str>>()[2],
|
||||
) {
|
||||
repos.push(PersistableRepo {
|
||||
// Ideally we wanna do this, but it moves `dir`.
|
||||
// path: entry.path().to_string_lossy().strip_prefix(dir).unwrap().to_string(),
|
||||
path: entry.path().to_string_lossy().to_string(),
|
||||
remote_url: remote.url().unwrap_or("None").to_owned(),
|
||||
head: head.to_owned(),
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue
Block a user