- Use git to detect the latest stable branch, rather than hardcoding it, but only run the git detection when the working branch is not already a stable or releng branch.
- Handle the case where the script is run outside a src or ports repository.
- Fix a pattern to match .git instead of *git`.
Details
- Reviewers
emaste andrew jrtc27 - Group Reviewers
releng - Commits
- rGe57d72a7f35c: mfc-candidates: Improve branch detection and repository handling
Diff Detail
- Repository
- rG FreeBSD src repository
- Lint
Lint Not Applicable - Unit
Tests Not Applicable
Event Timeline
@andrew, it will be the same situation as now, when we have to choose whether to list MFC candidates for stable/14 or stable/15 by default. If I understood our IRC conversation correctly, you requested mfc-candidates be updated to tell you your stable/15 MFC candidates by default. This change does that and will automatically do it for stable/16 as soon as stable/17 is tagged.
When there are multiple active stable branches, users can set pwd to check MFC candidates for other branches. For example, with this change, if you want to see MFC candidates for stable/14, check out stable/14 and run the script. When stable/17 is tagged and you want to see MFC candidations for stable/15, check out stable/15 before running the script.
tools/tools/git/mfc-candidates.lua | ||
---|---|---|
144 | Setting to_branch here is the fallback if we don't pick up a branch from the working tree; it would be good to avoid execing git to fetch the latest branch if we're just going to throw it away in many cases. Better would be to set it to nil here, and add this as below the string.match(cur_branch cases below |
Incorporate @emaste's suggestion.
Also, when the script was run from outside of a git repository, the output would be
fatal: not a git repository (or any parent up to mount point /usr) Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set). /usr/libexec/flua: /usr/src/tools/tools/git/mfc-candidates.lua:134: bad argument #1 to 'gsub' (string expected, got nil) stack traceback: [C]: in function 'string.gsub' /usr/src/tools/tools/git/mfc-candidates.lua:134: in local 'main' /usr/src/tools/tools/git/mfc-candidates.lua:217: in main chunk [C]: in ?
With the added error checking, it's simply
pwd is not under a ports or src repository.
tools/tools/git/mfc-candidates.lua | ||
---|---|---|
152 | sorry for not being explicit earlier -- to_branch is optionally set by the two earlier cases, so we want to allow them to set it if appropriate, or choose the default if neither picked up a default |
tools/tools/git/mfc-candidates.lua | ||
---|---|---|
152 | Sorry if I'm being dense, but isn't that what's happening? Before:
After:
The overall logic is the same. The only difference is that the default branch is not hard-coded, and now the new git command is only run when the checked out branch is neither stable/x nor releng/x. Did you mean something different by "choose the default"? |
tools/tools/git/mfc-candidates.lua | ||
---|---|---|
152 | Sorry, I guess I confused myself -- I guess I thought that to_branch was not unconditionally assigned in each of the if cases. |