diff options
| -rw-r--r-- | src/git_remote_helper.rs | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/src/git_remote_helper.rs b/src/git_remote_helper.rs index 793e714..506fd5e 100644 --- a/src/git_remote_helper.rs +++ b/src/git_remote_helper.rs | |||
| @@ -98,22 +98,10 @@ async fn main() -> Result<()> { | |||
| 98 | push(&git_repo.git_repo, url, &mut temp_remote, &stdin, refspec)?; | 98 | push(&git_repo.git_repo, url, &mut temp_remote, &stdin, refspec)?; |
| 99 | } | 99 | } |
| 100 | ["list"] => { | 100 | ["list"] => { |
| 101 | temp_remote.connect(git2::Direction::Fetch)?; | 101 | list(&mut temp_remote, false)?; |
| 102 | for head in temp_remote.list()? { | ||
| 103 | println!("{} {}", head.oid(), head.name()); | ||
| 104 | } | ||
| 105 | temp_remote.disconnect()?; | ||
| 106 | println!(); | ||
| 107 | } | 102 | } |
| 108 | ["list", "for-push"] => { | 103 | ["list", "for-push"] => { |
| 109 | temp_remote.connect(git2::Direction::Fetch)?; | 104 | list(&mut temp_remote, true)?; |
| 110 | for head in temp_remote.list()? { | ||
| 111 | if head.name() != "HEAD" { | ||
| 112 | println!("{} {}", head.oid(), head.name()); | ||
| 113 | } | ||
| 114 | } | ||
| 115 | temp_remote.disconnect()?; | ||
| 116 | println!(); | ||
| 117 | } | 105 | } |
| 118 | [] => { | 106 | [] => { |
| 119 | return Ok(()); | 107 | return Ok(()); |
| @@ -150,6 +138,18 @@ fn nostr_git_url_to_repo_coordinates(url: &str) -> Result<HashSet<Coordinate>> { | |||
| 150 | Ok(repo_coordinattes) | 138 | Ok(repo_coordinattes) |
| 151 | } | 139 | } |
| 152 | 140 | ||
| 141 | fn list(temp_remote: &mut Remote, for_push: bool) -> Result<()> { | ||
| 142 | temp_remote.connect(git2::Direction::Fetch)?; | ||
| 143 | for head in temp_remote.list()? { | ||
| 144 | if !for_push || head.name() != "HEAD" { | ||
| 145 | println!("{} {}", head.oid(), head.name()); | ||
| 146 | } | ||
| 147 | } | ||
| 148 | temp_remote.disconnect()?; | ||
| 149 | println!(); | ||
| 150 | Ok(()) | ||
| 151 | } | ||
| 152 | |||
| 153 | fn fetch(temp_remote: &mut Remote, stdin: &Stdin, refstr: &str) -> Result<()> { | 153 | fn fetch(temp_remote: &mut Remote, stdin: &Stdin, refstr: &str) -> Result<()> { |
| 154 | temp_remote.connect(git2::Direction::Fetch)?; | 154 | temp_remote.connect(git2::Direction::Fetch)?; |
| 155 | temp_remote.download(&get_refstrs_from_fetch_batch(stdin, refstr)?, None)?; | 155 | temp_remote.download(&get_refstrs_from_fetch_batch(stdin, refstr)?, None)?; |