-
Notifications
You must be signed in to change notification settings - Fork 114
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add git node staging
command
#875
Open
ruyadorno
wants to merge
4
commits into
nodejs:main
Choose a base branch
from
ruyadorno:add-git-node-staging-cmd
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
import CLI from '../../lib/cli.js'; | ||
import { runPromise } from '../../lib/run.js'; | ||
import { Staging } from '../../lib/staging.js'; | ||
|
||
export const command = 'staging'; | ||
export const describe = 'Automatic port commits to a release line branch'; | ||
|
||
const stagingOptions = { | ||
autoSkip: { | ||
describe: 'Automatically skip commits with conflicts that have to be manually resolved', | ||
type: 'boolean' | ||
}, | ||
backport: { | ||
describe: 'The PR ID / number to backport, skip staging commits', | ||
type: 'number' | ||
}, | ||
continue: { | ||
describe: 'Continue the staging process after a conflict', | ||
type: 'boolean' | ||
}, | ||
paginate: { | ||
describe: 'Sets a maximum number of commits to port', | ||
type: 'number' | ||
}, | ||
releaseLine: { | ||
describe: 'The major version of the target release', | ||
type: 'number' | ||
}, | ||
reportDestination: { | ||
describe: 'The destination to write the report to. Possible values are: ' + | ||
'stdout, github, or a file path, defaults to an interactive prompt.', | ||
type: 'string', | ||
default: undefined | ||
}, | ||
reporter: { | ||
describe: 'The reporter to use for the output', | ||
type: 'string', | ||
default: 'markdown' | ||
}, | ||
reset: { | ||
describe: 'Reset the staging process', | ||
type: 'boolean' | ||
}, | ||
skip: { | ||
describe: 'Continue the staging process marking the current commit as skipped', | ||
type: 'boolean' | ||
}, | ||
skipGH: { | ||
describe: 'Skip all `gh` cli actions. Will not read / add label to GitHub PRs', | ||
type: 'boolean' | ||
} | ||
}; | ||
|
||
export function builder(yargs) { | ||
return yargs | ||
.options(stagingOptions) | ||
.example('git node staging --releaseLine=23', | ||
'Port commits to the v1.x-staging branch'); | ||
} | ||
|
||
export function handler(argv) { | ||
const logStream = process.stdout.isTTY ? process.stdout : process.stderr; | ||
const cli = new CLI(logStream); | ||
const dir = process.cwd(); | ||
|
||
return runPromise(main(argv, cli, dir)).catch((err) => { | ||
if (cli.spinner.enabled) { | ||
cli.spinner.fail(); | ||
} | ||
throw err; | ||
}); | ||
} | ||
|
||
async function main(argv, cli, dir) { | ||
const { | ||
autoSkip, | ||
backport, | ||
paginate, | ||
releaseLine, | ||
reportDestination, | ||
reporter, | ||
reset, | ||
skip, | ||
skipGH | ||
} = argv; | ||
const staging = new Staging({ | ||
cli, | ||
dir, | ||
cont: argv.continue, | ||
autoSkip, | ||
paginate, | ||
releaseLine, | ||
reportDestination, | ||
reporter, | ||
skip, | ||
skipGH | ||
}); | ||
if (backport) { | ||
await staging.requestBackport(backport); | ||
} else if (reset) { | ||
await staging.reset(); | ||
} else { | ||
await staging.run(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand why this option is on
git node staging
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The idea is that this is a convenience helper for when, let's say, you end up having to remove a commit from the staging branch after figuring out it was breaking CI, then as a releaser you can just run
git node staging --backport=<PR_ID>
after rebasing / removing the offending commits from the staging branch.It's part of
git node staging
more from an implementation convenience point of view since all the internal logic is already there.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, it's worth noting that
git node staging --backport=<PR_ID>
should send an automated comment by default in the original PR, which it's not going to happen in the regulargit node staging
automation.