Skip to content

refactor: decompose fetch_latest_tag into focused helpers with module-level constant#85

Merged
redpanda-f merged 2 commits intofeat/redpanda/latesttag-resolverfrom
copilot/sub-pr-83
Mar 9, 2026
Merged

refactor: decompose fetch_latest_tag into focused helpers with module-level constant#85
redpanda-f merged 2 commits intofeat/redpanda/latesttag-resolverfrom
copilot/sub-pr-83

Conversation

Copy link
Contributor

Copilot AI commented Mar 9, 2026

fetch_latest_tag was a ~40-line function mixing repo creation, network I/O, output parsing, and tag selection — violating the project's small-functions / no-magic-strings guidelines.

Changes

  • TEMP_DIR_PREFIX constant — lifts "foc-devnet-tag-probe-" out of TempBareRepo::create into a module-level constant
  • fetch_refs(repo, url, branch) — isolates the git fetch --tags --filter=blob:none invocation
  • list_merged_tags(repo, branch) — isolates git tag --merged … --sort=-creatordate, returns raw stdout
  • pick_first_tag(stdout, branch, url) — isolates first-non-empty-line selection

fetch_latest_tag becomes a 5-line orchestrator:

fn fetch_latest_tag(url: &str, branch: &str) -> Result<String, Box<dyn std::error::Error>> {
    info!("Fetching newest tag on branch '{}' from {}", branch, url);
    let repo = TempBareRepo::create()?;
    fetch_refs(&repo, url, branch)?;
    let stdout = list_merged_tags(&repo, branch)?;
    pick_first_tag(&stdout, branch, url)
}

💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

…-level constant

Co-authored-by: redpanda-f <181817029+redpanda-f@users.noreply.github.com>
Copilot AI changed the title [WIP] Address feedback on Latesttag location resolver PR refactor: decompose fetch_latest_tag into focused helpers with module-level constant Mar 9, 2026
@redpanda-f redpanda-f marked this pull request as ready for review March 9, 2026 12:19
@redpanda-f redpanda-f merged commit 967a3b7 into feat/redpanda/latesttag-resolver Mar 9, 2026
@redpanda-f redpanda-f deleted the copilot/sub-pr-83 branch March 9, 2026 12:19
redpanda-f added a commit that referenced this pull request Mar 13, 2026
* feat: add LatestTag location resolver for init-time tag discovery

* makehappy: fmt

* Update src/commands/init/latest_resolver.rs

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Update src/commands/init/repositories.rs

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Update src/config.rs

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Update src/config.rs

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* refactor: decompose `fetch_latest_tag` into focused helpers with module-level constant (#85)

* Initial plan

* refactor: decompose fetch_latest_tag into focused helpers with module-level constant

Co-authored-by: redpanda-f <181817029+redpanda-f@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: redpanda-f <181817029+redpanda-f@users.noreply.github.com>

* fix: remove usage of deprecated methods

* fix: new resolver

* fixup: latesttag

* fixup: clippy issues

* Update src/config.rs

Co-authored-by: Rod Vagg <rod@vagg.org>

* Rename `_type` to `loc_type` in `resolve_with_default` (#91)

* Initial plan

* rename _type to loc_type in resolve_with_default

Co-authored-by: redpanda-f <181817029+redpanda-f@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: redpanda-f <181817029+redpanda-f@users.noreply.github.com>

* Simplify `latesttag` branch with early return, drop lifetime workaround (#93)

* Initial plan

* Simplify latesttag handling with early return, drop lifetimes dance

Co-authored-by: redpanda-f <181817029+redpanda-f@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: redpanda-f <181817029+redpanda-f@users.noreply.github.com>

* Fix invalid `v/*` glob example — replace with `v*` throughout (#92)

* Initial plan

* Replace invalid v/* glob pattern with v* in docs and code

Co-authored-by: redpanda-f <181817029+redpanda-f@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: redpanda-f <181817029+redpanda-f@users.noreply.github.com>

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com>
Co-authored-by: redpanda-f <181817029+redpanda-f@users.noreply.github.com>
Co-authored-by: Rod Vagg <rod@vagg.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants