git.go
func (r *Repo) Pull() error {
	r.Lock()
	defer r.Unlock()

	// prevent a pull if the last one was less than 5 seconds ago
	if gos.TimeSince(r.lastPull) < 5*time.Second {
		return nil
	}

	// keep last commit hash for comparison later
	lastCommit := r.lastCommit

	var err error
	// Attempt to pull at most numRetries times
	for i := 0; i < numRetries; i++ {
		if err = r.pull(); err == nil {
			break
		}
		Logger().Println(err)
	}

	if err != nil {
		return err
	}

	// check if there are new changes,
	// then execute post pull command
	if r.lastCommit == lastCommit {
		Logger().Println("No new changes.")
		return nil
	}
	return r.execThen()
}
func (r *Repo) Pull() error {
	r.Lock()
	defer r.Unlock()

	// prevent a pull if the last one was less than 5 seconds ago
	if gos.TimeSince(r.lastPull) < 5*time.Second {
		return nil
	}

	// keep last commit hash for comparison later
	lastCommit := r.lastCommit

	var err error
	// Attempt to pull at most numRetries times
	for i := 0; i < numRetries; i++ {
		if err = r.pull(); err == nil {
			break
		}
		Logger().Println(err)
	}

	if err != nil {
		return err
	}

	// check if there are new changes,
	// then execute post pull command
	if r.lastCommit == lastCommit {
		Logger().Println("No new changes.")
		return nil
	}
	return r.execThen()
}
func ( r * Repo ) Pull ( ) error { r . Lock ( ) defer r . Unlock ( ) // prevent a pull if the last one was less than 5 seconds ago if gos . TimeSince ( r . lastPull ) < 5 * time . Second { return nil } // keep last commit hash for comparison later lastCommit := r . lastCommit var err error // Attempt to pull at most numRetries times for i := 0 ; i < numRetries ; i ++ { if err = r . pull ( ) ; err == nil { break } Logger ( ) . Println ( err ) } if err != nil { return err } // check if there are new changes, // then execute post pull command if r . lastCommit == lastCommit { Logger ( ) . Println ( " " ) return nil } return r . execThen ( ) }
// Pull attempts a git pull.
// It retries at most numRetries times if error occurs
Pull attempts a git pull . It retries at most numRetries times if error occurs