Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tag support #62

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions src/rsl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,12 @@ pub fn all_push_entries_in_fetch_head(repo: &Repository, rsl: &RSL, ref_names: &
println!("ref_name: {:?}", ref_name);
match repo.find_branch(&format!("origin/{}", ref_name), BranchType::Remote) {
Ok(branch) => branch.get().target(),
Err(_) => None,
Err(_) => {
match repo.find_reference(&format!("refs/tags/{}", ref_name)) {
Ok(tag_ref) => tag_ref.target(),
Err(_) => None
}
},
}
})
.collect();
Expand Down Expand Up @@ -232,7 +237,8 @@ impl<'remote, 'repo> RSL<'remote, 'repo> {
let mut revwalk: Revwalk = self.repo.revwalk()?;
revwalk.push(self.remote_head)?;
let mut current = Some(self.remote_head);
let ref_name = format!("refs/heads/{}", branch);
let reference = git::get_ref_from_name(self.repo, branch).expect("failed to get ref");
let ref_name = reference.name().expect("failed to get ref name");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

extra space after let

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Error handling

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

while current != None {
if let Some(pe) = PushEntry::from_oid(self.repo, &current.unwrap())? {
if pe.ref_name() == ref_name {
Expand Down
4 changes: 3 additions & 1 deletion tests/integration_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,11 @@ sequential_test! {
do_work_on_branch(&context.local, "refs/heads/master");
tag_lightweight(&mut context.local, "v6.66");

assert_eq!((), git_rsl::secure_push_with_cleanup(&mut context.local, &RemoteName::new("origin"), &ReferenceName::new("v6.66")).expect("Could not run third push"));
assert_eq!((), git_rsl::secure_push_with_cleanup(&mut context.local, &RemoteName::new("origin"), &ReferenceName::new("v6.66")).expect("Could not push tag"));
let remote_tag = &context.remote.find_reference("refs/tags/v6.66").expect("reference not found");
assert!(remote_tag.is_tag());

assert_eq!((), git_rsl::secure_fetch_with_cleanup(&mut context.local, &RemoteName::new("origin"), &ReferenceName::new("v6.66")).expect("could not fetch tag"));

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wrap lines

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

}
}
}
Expand Down