
Security News
vlt Launches "reproduce": A New Tool Challenging the Limits of Package Provenance
vlt's new "reproduce" tool verifies npm packages against their source code, outperforming traditional provenance adoption in the JavaScript ecosystem.
delete-github-branches
Advanced tools
Delete GitHub Branches that match patterns.
includesBranchPatterns
excludesBranchPatterns
dryRun
modeInstall with npm:
npm install delete-github-branches
Usage
$ delete-github-branches
Options
--owner Owner name for repository: **owner**/repo
--repo Repo name for repository: owner/**repo**
--token GitHub Token. you can use als GITHUB_TOKEN env
--includesBranchPatterns includes branch patterns split by comma. Default: "/^.*$/" (all)
--excludesBranchPatterns excludes branch patterns split by comma. Default: "master,develop,dev,gh-pages"
--stalledDays Deletable days after the branch is stalled. Default: 30
--format Output formatter. Available: "markdown", "json". Default: "markdown"
--baseUrl GitHub API base Url.
--dryRun if this flag is on, run dry-run mode
--config path to config file
Examples
$ delete-github-branches --owner azu --repo delete-github-branches-test --token <TOKEN>
$ delete-github-branches --owner azu --repo delete-github-branches-test --token <TOKEN> --includesBranchPatterns "/feature\/.*/" --dryRun
Also this package includes helper cli tool.
delete-github-branches-check-branch-name
just detect if the branch name is matched patterns.
Usage
$ delete-github-branches-check-branch-name [branchName]
Options
--includesBranchPatterns includes branch patterns split by comma. Default: "/^.*$/" (all)
--excludesBranchPatterns excludes branch patterns split by comma. Default: "master,develop,dev,gh-pages"
--config path to config file
Examples
$ delete-github-branches-check-branch-name "feature/009"
$ echo $? # 0
# It will be alive and exit code: 0
$ delete-github-branches-check-branch-name "patch-101"
$ echo $? # 1
# It will be deleted and exit code: 1
Config file is following JSON format.
All property is optional and its can be combined with command line flags.
{
/**
* Repository owner name
*/
owner?: string;
/**
* Repository name
*/
repo?: string;
/**
* allow list that match branch names
* Match all branches without excludesBranchPatterns's default by default
* It means that matches branches without ["master", "develop", "dev", "gh-pages"]
*
* You can use RegExp-like string for this list
* https://github.com/textlint/regexp-string-matcher#regexp-like-string
* Default: ["/^.*$/"]
*/
includesBranchPatterns?: string[];
/**
* Deny list that match branch names
* You can use RegExp-like string for this list
* https://github.com/textlint/regexp-string-matcher#regexp-like-string
* Default: ["master", "develop", "dev", "gh-pages"]
*/
excludesBranchPatterns?: string[];
/**
* You can set deletable stalled days after the branch is last pushed
* Delete branches that are stalled 30 days by default
* if today >= lastPushedDate + 30, its deletable
* Default: 30
*/
stalledDays?: number;
/**
* Default: 'https://api.github.com'
*/
baseUrl?: string;
/**
* GitHub Token
*/
token?: string;
/**
* If `dryRun` is `true`, does not delete actually
* Dry-run mode fetch and dump
* Default: false
*/
dryRun?: boolean;
}
For example, delete-github-branches.json
is following config.
delete-github-branches.json
:
{
"includesBranchPatterns": ["/^.*$/"],
"excludesBranchPatterns": ["master", "develop", "dev", "gh-pages", "/^feature\/.*$/"]
}
And you can pass other options as command line flags
$ GITHUB_TOKEN=$GH_TOKEN delete-github-branches --owner azu --repo delete-github-branches-test --config ./delete-github-branches.json
(async () => {
const results = await deleteGitHubBranches({
owner: "azu",
repo: "delete-github-branches-test",
excludesBranchPatterns: ["master", "develop", "/feature/.*/"],
token: process.env.token!,
dryRun: true // <= dry run mode
});
assert.deepStrictEqual(results, [
{ branchName: "develop", deleted: false, reason: "It is ignored by includes/excludes patterns" },
{ branchName: "feature/a", deleted: false, reason: "It is ignored by includes/excludes patterns" },
{ branchName: "feature/b", deleted: false, reason: "It is ignored by includes/excludes patterns" },
{ branchName: "master", deleted: false, reason: "It is ignored by includes/excludes patterns" },
{ branchName: "will-be-deleted", deleted: true }
]);
})()
See Releases page.
Add .env
with token
GITHUB_TOKEN=XXXX
Run tests
npm test
Pull requests and stars are always welcome.
For bugs and feature requests, please create an issue.
git checkout -b my-new-feature
git commit -am 'Add some feature'
git push origin my-new-feature
MIT © azu
FAQs
Delete GitHub Branches that match patterns.
We found that delete-github-branches demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
vlt's new "reproduce" tool verifies npm packages against their source code, outperforming traditional provenance adoption in the JavaScript ecosystem.
Research
Security News
Socket researchers uncovered a malicious PyPI package exploiting Deezer’s API to enable coordinated music piracy through API abuse and C2 server control.
Research
The Socket Research Team discovered a malicious npm package, '@ton-wallet/create', stealing cryptocurrency wallet keys from developers and users in the TON ecosystem.