aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/util.rs26
1 files changed, 8 insertions, 18 deletions
diff --git a/src/util.rs b/src/util.rs
index 9a75111..7950d2a 100644
--- a/src/util.rs
+++ b/src/util.rs
@@ -133,12 +133,6 @@ pub fn print_collected_packages(packages: &PackageList, message: &str) {
pub fn pull_latest_tag(path: &Path) -> Result<(), git2::Error> {
let repo = Repository::open(path)?;
- let head = repo.head()?;
- let branch = head
- .shorthand()
- .ok_or_else(|| git2::Error::from_str("Could not determine current branch"))?
- .to_string();
-
let mut callbacks = RemoteCallbacks::new();
callbacks.credentials(|_url, username_from_url, _allowed| {
Cred::ssh_key_from_agent(username_from_url.unwrap())
@@ -151,15 +145,14 @@ pub fn pull_latest_tag(path: &Path) -> Result<(), git2::Error> {
remote.fetch(&["refs/tags/*:refs/tags/*"], Some(&mut fetch_options), None)?;
let tag_names = repo.tag_names(None)?;
-
let mut latest_commit = None;
let mut latest_time = 0;
for name in tag_names.iter().flatten() {
let obj = repo.revparse_single(&format!("refs/tags/{}", name))?;
let commit = obj.peel_to_commit()?;
-
let time = commit.time().seconds();
+
if time > latest_time {
latest_time = time;
latest_commit = Some(commit);
@@ -168,21 +161,18 @@ pub fn pull_latest_tag(path: &Path) -> Result<(), git2::Error> {
let latest_commit = latest_commit.ok_or_else(|| git2::Error::from_str("No tags found"))?;
- let annotated = repo.find_annotated_commit(latest_commit.id())?;
- let (analysis, _) = repo.merge_analysis(&[&annotated])?;
+ let current_commit = repo.head()?.peel_to_commit()?;
- if analysis.is_fast_forward() {
- let refname = format!("refs/heads/{}", branch);
- let mut reference = repo.find_reference(&refname)?;
- reference.set_target(latest_commit.id(), "set to latest tag")?;
- repo.set_head_detached(latest_commit.id())?;
- repo.checkout_head(Some(CheckoutBuilder::default().force()))?;
- } else if !analysis.is_up_to_date() {
- println!("Cannot fast-forward to latest tag.");
+ if current_commit.id() == latest_commit.id() {
+ return Ok(());
}
+ repo.set_head_detached(latest_commit.id())?;
+ repo.checkout_head(Some(CheckoutBuilder::default().force()))?;
+
Ok(())
}
+
pub fn pull_repo(path: &Path) -> Result<(), git2::Error> {
let repo = Repository::open(path)?;
='//www.gravatar.com/avatar/ed70b39a62b64121c8f0ab7e10b3873a?s=13&d=retro' width='13' height='13' alt='Gravatar' /> Davide Del Zompo 1-2/+3 2015-10-04fix paste from clipboard (ctrl+shift+y)Gravatar Hiltjo Posthuma 1-0/+1 2015-09-28minor style fixGravatar Hiltjo Posthuma 1-1/+2 2015-09-28Remove function prototypes and reorder functions accordinglyGravatar FRIGN 1-80/+64 2015-09-28Untypedef struct itemGravatar FRIGN 1-10/+9 2015-09-28Fix the conversion from microseconds to nanosecondsGravatar Quentin Rameau 1-1/+1 2015-09-28Replace deprecated usleep() with nanosleep()Gravatar Quentin Rameau 1-2/+3 2015-09-28config.mk: use -std=c99Gravatar Hiltjo Posthuma 1-1/+1 2015-09-27dmenu: style improvementsGravatar Hiltjo Posthuma 1-204/+213 2015-09-27drw style improvementsGravatar Hiltjo Posthuma 2-93/+106 2015-09-27separate program-specific c99 bool and X11Gravatar Hiltjo Posthuma 2-11/+10 2015-09-27config.mk: fix _XOPEN_SOURCE=700 for getline()Gravatar Hiltjo Posthuma 1-1/+1 2015-09-27config.mk: improve feature test checkGravatar Hiltjo Posthuma 1-1/+1 2015-08-06Fixed typo introduced by shared codeGravatar Eric Pruitt 1-1/+1 2015-07-19stest: get rid of getopt, use suckless arg.hGravatar Hiltjo Posthuma 3-53/+141 2015-07-19config.mk: add FREETYPELIBS and FREETYPEINCGravatar Hiltjo Posthuma 1-3/+9 2015-07-19fix prompt color style how it used to beGravatar Hiltjo Posthuma 1-1/+1 2015-06-27Use libdraw: add Xft and fallback-fonts support to graphics libGravatar Hiltjo Posthuma 11-316/+684 2014-09-17applied Hiltjo's patch as suggested on the ml to fix ControlMask for C-j and C-mGravatar Anselm R Garbe 2-2/+5 2014-07-30fix crash with ctrl-enter as inputGravatar Hiltjo Posthuma 1-1/+2 2014-05-29updated copyright notices in LICENSE and dmenu.c fileGravatar Anselm R Garbe 2-2/+2 2013-08-13applied Martin Kühl's inverse matching flag to stestGravatar Anselm R Garbe 2-4/+7 2013-08-02applied Martti Kühne's dmenu monitor patchGravatar Anselm R Garbe 3-4/+14 2013-06-28accepted vi'is exit approach ^[ (suggested by Arkaduisz)Gravatar Anselm R Garbe 1-0/+2