예제 #1
0
// Update updates the given DEPS roll in the recent rolls list.
func (r *RecentRolls) Update(roll *autoroll.AutoRollIssue) error {
	if err := roll.Validate(); err != nil {
		return err
	}

	r.mtx.Lock()
	defer r.mtx.Unlock()
	if err := r.db.UpdateRoll(roll); err != nil {
		return err
	}
	return r.refreshRecentRolls()
}
예제 #2
0
// Add adds a DEPS roll to the recent rolls list.
func (r *RecentRolls) Add(roll *autoroll.AutoRollIssue) error {
	if err := roll.Validate(); err != nil {
		return err
	}

	r.mtx.Lock()
	defer r.mtx.Unlock()

	// Refuse to insert more rolls if we already have an active roll.
	if r.currentRoll() != nil {
		return fmt.Errorf("There is already an active roll. Cannot add another.")
	}

	// Validate the new roll.
	if roll.Closed {
		return fmt.Errorf("Cannot insert a new roll which is already closed.")
	}

	if err := r.db.InsertRoll(roll); err != nil {
		return err
	}
	return r.refreshRecentRolls()
}