Date: Thu, 2 Oct 2025 16:47:48 GMT From: Joseph Mingrone <jrm@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org Subject: git: e57d72a7f35c - main - mfc-candidates: Improve branch detection and repository handling Message-ID: <202510021647.592Glmt2008578@gitrepo.freebsd.org>
next in thread | raw e-mail | index | archive | help
The branch main has been updated by jrm: URL: https://cgit.FreeBSD.org/src/commit/?id=e57d72a7f35c3fc80dc9ac744056b2354b1be741 commit e57d72a7f35c3fc80dc9ac744056b2354b1be741 Author: Joseph Mingrone <jrm@FreeBSD.org> AuthorDate: 2025-09-22 18:18:20 +0000 Commit: Joseph Mingrone <jrm@FreeBSD.org> CommitDate: 2025-10-02 16:47:26 +0000 mfc-candidates: Improve branch detection and repository handling - Use git to detect the latest stable branch rather than hardcoding it. - Handle the case where the script is run outside a src or ports repository. - Fix a pattern to match .git instead of *git. Reviewed by: andrew, releng (emaste) Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D52681 --- tools/tools/git/mfc-candidates.lua | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/tools/tools/git/mfc-candidates.lua b/tools/tools/git/mfc-candidates.lua index d2865a892971..a1420dc726da 100755 --- a/tools/tools/git/mfc-candidates.lua +++ b/tools/tools/git/mfc-candidates.lua @@ -129,16 +129,18 @@ local function main() local author = os.getenv("USER") or "" local dirspec = nil - local url = exec_command("git remote get-url freebsd") - local freebsd_repo = string.match(url, "[^/]+$") - freebsd_repo = string.gsub(freebsd_repo, ".git$", "") + local url = exec_command("git remote get-url freebsd 2>/dev/null") + local freebsd_repo + if url and url ~= "" then + freebsd_repo = string.match(url, "[^/]+$") + freebsd_repo = string.gsub(freebsd_repo, "%.git$", "") + end if freebsd_repo == "ports" or freebsd_repo == "freebsd-ports" then local year = os.date("%Y") local month = os.date("%m") local qtr = math.ceil(month / 3) to_branch = "freebsd/" .. year .. "Q" .. qtr elseif freebsd_repo == "src" or freebsd_repo == "freebsd-src" then - to_branch = "freebsd/stable/14" -- If pwd is a stable or release branch tree, default to it. local cur_branch = exec_command("git symbolic-ref --short HEAD") if string.match(cur_branch, "^stable/") then @@ -147,6 +149,11 @@ local function main() to_branch = cur_branch local major = string.match(cur_branch, "%d+") from_branch = "freebsd/stable/" .. major + else + -- Use latest stable branch. + to_branch = exec_command("git for-each-ref --sort=-v:refname " .. + "--format='%(refname:lstrip=2)' " .. + "refs/remotes/freebsd/stable/* --count=1") end else print("pwd is not under a ports or src repository.")
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202510021647.592Glmt2008578>