mirror of
https://github.com/msfjarvis/gitice
synced 2025-08-14 11:47:01 +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
1 changed files with 19 additions and 7 deletions
26
src/main.rs
26
src/main.rs
|
@ -31,13 +31,25 @@ fn main() -> anyhow::Result<()> {
|
||||||
|
|
||||||
let head = repo.head()?;
|
let head = repo.head()?;
|
||||||
if let Some(head) = head.name() {
|
if let Some(head) = head.name() {
|
||||||
repos.push(PersistableRepo {
|
if let Ok(upstream) = repo.branch_upstream_name(head) {
|
||||||
// Ideally we wanna do this, but it moves `dir`.
|
if let Ok(remote) = repo.find_remote(
|
||||||
// path: entry.path().to_string_lossy().strip_prefix(dir).unwrap().to_string(),
|
// This is a rather ugly hack, but not sure how else to get the required name
|
||||||
path: entry.path().to_string_lossy().to_string(),
|
// doesn't seem to work with the full name such as `refs/remotes/origin/master`
|
||||||
remote_url: repo.remotes()?.get(0).unwrap_or("None").to_string(),
|
upstream
|
||||||
head: head.to_string(),
|
.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…
Add table
Add a link
Reference in a new issue