Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
5 changes: 5 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,11 @@ git push origin release/v<VERSION>
git-api pr create --title "release: Version <VERSION>" --body "..."
```

## Git Rules

- **NEVER `--amend` unless you verify HEAD is your commit first** — always run `git log --oneline -1` before amending to confirm you're amending the right commit.
- **When a commit fails (hooks modified files), just commit again normally** — do NOT use `--amend`, or you'll amend the parent commit. Simply stage the changes and `git commit -m "..."` again.

### Note on Protected Branches

The `master` branch is protected. Releases must go through a PR. After merge, tagging and GitHub release are automated.
45 changes: 28 additions & 17 deletions src/timer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,31 @@ where
}
}

fn play_beep() -> Result<()> {
for _ in 0..BEEP_REPETITIONS {
sleep(stdDuration::from_millis(SOUND_START_DELAY));
if beep(BEEP_FREQ, stdDuration::from_millis(BEEP_DURATION)).is_err() {
sleep(stdDuration::from_millis(BEEP_DURATION));
}

let remaining_delay = BEEP_DELAY.saturating_sub(SOUND_START_DELAY);
if remaining_delay > 0 {
sleep(stdDuration::from_millis(remaining_delay));
}
}
Ok(())
}

fn play_sound() -> Result<()> {
let sound = Sound::new()?;

for _ in 0..BEEP_REPETITIONS {
sound.play()?;
sleep(stdDuration::from_millis(BEEP_DELAY));
}
Ok(())
}

pub fn countdown<W>(w: &mut W, end: OffsetDateTime, opts: &Opts) -> Result<()>
where
W: io::Write,
Expand All @@ -123,23 +148,9 @@ where
}

if !opts.silence {
match Sound::new() {
Ok(sound) => {
for _ in 0..BEEP_REPETITIONS {
sleep(stdDuration::from_millis(SOUND_START_DELAY));
if beep(BEEP_FREQ, stdDuration::from_millis(BEEP_DURATION)).is_err()
{
sleep(stdDuration::from_millis(BEEP_DURATION));
}

if sound.play().is_err() {
break;
}
sleep(stdDuration::from_millis(BEEP_DELAY));
}
}
Err(e) => return Err(e),
}
let sound_handle = std::thread::spawn(|| play_sound().unwrap());
play_beep()?;
sound_handle.join().map_err(|_| "Sound thread panicked")?;
}
return Ok(());
}
Expand Down
Loading