codeowners-git 1.4.2 → 1.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -0
- package/dist/cli.js +27 -16
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -102,11 +102,16 @@ Options:
|
|
|
102
102
|
- `--upstream, -u` Upstream branch name (defaults to local branch name)
|
|
103
103
|
- `--force, -f` Force push to remote
|
|
104
104
|
- `--keep-branch-on-failure, -k` Keep the created branch even if operation fails
|
|
105
|
+
- `--append` Add commits to existing branch instead of creating a new one
|
|
105
106
|
|
|
106
107
|
Example:
|
|
107
108
|
|
|
108
109
|
```bash
|
|
110
|
+
# Create a new branch
|
|
109
111
|
codeowners-git branch -o @myteam -b "feature/new-feature" -m "Add new feature" -p
|
|
112
|
+
|
|
113
|
+
# Add more commits to the same branch later
|
|
114
|
+
codeowners-git branch -o @myteam -b "feature/new-feature" -m "Add more changes" --append -p
|
|
110
115
|
```
|
|
111
116
|
|
|
112
117
|
### `multi-branch`
|
|
@@ -132,6 +137,7 @@ Options:
|
|
|
132
137
|
- `--default-owner, -d` Default owner to use when no codeowners are found for changed files
|
|
133
138
|
- `--ignore` Comma-separated patterns to exclude codeowners (e.g., 'team-a,team-b')
|
|
134
139
|
- `--include` Comma-separated patterns to include codeowners (e.g., 'team-_,@org/_')
|
|
140
|
+
- `--append` Add commits to existing branches instead of creating new ones
|
|
135
141
|
|
|
136
142
|
> **Note:** You cannot use both `--ignore` and `--include` options at the same time.
|
|
137
143
|
|
|
@@ -149,6 +155,9 @@ codeowners-git multi-branch -b "feature/new-feature" -m "Add new feature" --incl
|
|
|
149
155
|
|
|
150
156
|
# Use default owner when no codeowners found
|
|
151
157
|
codeowners-git multi-branch -b "feature/new-feature" -m "Add new feature" -d "@default-team"
|
|
158
|
+
|
|
159
|
+
# Add more commits to existing branches
|
|
160
|
+
codeowners-git multi-branch -b "feature/new-feature" -m "Add more changes" --append -p
|
|
152
161
|
```
|
|
153
162
|
|
|
154
163
|
This will:
|
package/dist/cli.js
CHANGED
|
@@ -14786,7 +14786,7 @@ var branch = async (options) => {
|
|
|
14786
14786
|
if (!options.branch || !options.message || !options.owner) {
|
|
14787
14787
|
throw new Error("Missing required options for branch creation");
|
|
14788
14788
|
}
|
|
14789
|
-
log.info("Starting branch creation process...");
|
|
14789
|
+
log.info(options.append ? "Starting branch update process..." : "Starting branch creation process...");
|
|
14790
14790
|
originalBranch = await getCurrentBranch();
|
|
14791
14791
|
log.info(`Currently on branch: ${originalBranch}`);
|
|
14792
14792
|
filesToCommit = await getOwnerFiles(options.owner, options.isDefaultOwner || false);
|
|
@@ -14797,13 +14797,19 @@ var branch = async (options) => {
|
|
|
14797
14797
|
log.file(`Files to be committed:
|
|
14798
14798
|
${filesToCommit.join(`
|
|
14799
14799
|
`)}`);
|
|
14800
|
-
|
|
14801
|
-
|
|
14800
|
+
const branchAlreadyExists = await branchExists(options.branch);
|
|
14801
|
+
if (branchAlreadyExists && !options.append) {
|
|
14802
|
+
throw new Error(`Branch "${options.branch}" already exists. Use --append to add commits to it, or use a different name.`);
|
|
14802
14803
|
}
|
|
14803
14804
|
try {
|
|
14804
|
-
|
|
14805
|
-
|
|
14806
|
-
|
|
14805
|
+
if (branchAlreadyExists && options.append) {
|
|
14806
|
+
log.info(`Checking out existing branch "${options.branch}"...`);
|
|
14807
|
+
await checkout(options.branch);
|
|
14808
|
+
} else {
|
|
14809
|
+
log.info(`Creating new branch "${options.branch}"...`);
|
|
14810
|
+
await createBranch(options.branch);
|
|
14811
|
+
newBranchCreated = true;
|
|
14812
|
+
}
|
|
14807
14813
|
log.info(`Committing changes with message: "${options.message}" ${!options.verify ? "(no-verify)" : ""}...`);
|
|
14808
14814
|
await commitChanges(filesToCommit, {
|
|
14809
14815
|
message: options.message ?? "",
|
|
@@ -14819,7 +14825,11 @@ var branch = async (options) => {
|
|
|
14819
14825
|
}
|
|
14820
14826
|
log.info(`Checking out original branch "${originalBranch}"...`);
|
|
14821
14827
|
await checkout(originalBranch);
|
|
14822
|
-
|
|
14828
|
+
if (branchAlreadyExists && options.append) {
|
|
14829
|
+
log.success(options.push ? `Changes committed to existing branch "${options.branch}" and pushed to remote.` : `Changes committed to existing branch "${options.branch}".`);
|
|
14830
|
+
} else {
|
|
14831
|
+
log.success(options.push ? `Branch "${options.branch}" created, changes committed, and pushed to remote.` : `Branch "${options.branch}" created and changes committed.`);
|
|
14832
|
+
}
|
|
14823
14833
|
} catch (operationError) {
|
|
14824
14834
|
log.error(`Operation failed: ${operationError}`);
|
|
14825
14835
|
if (newBranchCreated) {
|
|
@@ -14866,7 +14876,7 @@ var multiBranch = async (options) => {
|
|
|
14866
14876
|
if (options.ignore && options.include) {
|
|
14867
14877
|
throw new Error("Cannot use both --ignore and --include options at the same time");
|
|
14868
14878
|
}
|
|
14869
|
-
log.info("Starting multi-branch creation process...");
|
|
14879
|
+
log.info(options.append ? "Starting multi-branch update process..." : "Starting multi-branch creation process...");
|
|
14870
14880
|
const changedFiles = await getChangedFiles();
|
|
14871
14881
|
if (changedFiles.length === 0) {
|
|
14872
14882
|
throw new Error("No changed files found in the repository");
|
|
@@ -14921,7 +14931,7 @@ var multiBranch = async (options) => {
|
|
|
14921
14931
|
const sanitizedOwner = owner.replace(/[^a-zA-Z0-9-_@]/g, "-").replace(/^@/, "");
|
|
14922
14932
|
const branchName = `${options.branch}/${sanitizedOwner}`;
|
|
14923
14933
|
const commitMessage = `${options.message} - ${owner}`;
|
|
14924
|
-
log.info(`Creating branch for ${owner}...`);
|
|
14934
|
+
log.info(options.append ? `Updating branch for ${owner}...` : `Creating branch for ${owner}...`);
|
|
14925
14935
|
await branch({
|
|
14926
14936
|
owner,
|
|
14927
14937
|
branch: branchName,
|
|
@@ -14932,16 +14942,17 @@ var multiBranch = async (options) => {
|
|
|
14932
14942
|
upstream: options.upstream,
|
|
14933
14943
|
force: options.force,
|
|
14934
14944
|
keepBranchOnFailure: options.keepBranchOnFailure,
|
|
14935
|
-
isDefaultOwner: owner === options.defaultOwner
|
|
14945
|
+
isDefaultOwner: owner === options.defaultOwner,
|
|
14946
|
+
append: options.append
|
|
14936
14947
|
});
|
|
14937
14948
|
results.success.push(owner);
|
|
14938
14949
|
} catch (error) {
|
|
14939
|
-
log.error(`Failed to create branch for ${owner}: ${error}`);
|
|
14950
|
+
log.error(`Failed to ${options.append ? "update" : "create"} branch for ${owner}: ${error}`);
|
|
14940
14951
|
results.failure.push(owner);
|
|
14941
14952
|
}
|
|
14942
14953
|
}
|
|
14943
|
-
log.header("Multi-branch creation summary");
|
|
14944
|
-
log.info(`Successfully created branches for ${results.success.length} of ${codeowners2.length} codeowners`);
|
|
14954
|
+
log.header(options.append ? "Multi-branch update summary" : "Multi-branch creation summary");
|
|
14955
|
+
log.info(options.append ? `Successfully updated branches for ${results.success.length} of ${codeowners2.length} codeowners` : `Successfully created branches for ${results.success.length} of ${codeowners2.length} codeowners`);
|
|
14945
14956
|
if (results.success.length) {
|
|
14946
14957
|
log.success(`Successful: ${results.success.join(", ")}`);
|
|
14947
14958
|
}
|
|
@@ -14954,7 +14965,7 @@ var multiBranch = async (options) => {
|
|
|
14954
14965
|
}
|
|
14955
14966
|
};
|
|
14956
14967
|
// package.json
|
|
14957
|
-
var version = "1.
|
|
14968
|
+
var version = "1.5.0";
|
|
14958
14969
|
|
|
14959
14970
|
// src/commands/version.ts
|
|
14960
14971
|
function getVersion() {
|
|
@@ -14965,6 +14976,6 @@ function getVersion() {
|
|
|
14965
14976
|
var program2 = new Command;
|
|
14966
14977
|
program2.name("codeowners").description("CLI tool for grouping and managing staged files by CODEOWNERS").version(getVersion());
|
|
14967
14978
|
program2.command("list").description("Lists all git changed files by CODEOWNER").option("-o, --owner <owner>", "Filter by specific code owner").option("-i, --include <patterns>", "Filter by owner patterns").action(listCodeowners);
|
|
14968
|
-
program2.command("branch").description("Create new branch with codeowner changes").requiredOption("-o, --owner <owner>", "Code owner name").requiredOption("-b, --branch <branch>", "Branch name").requiredOption("-m, --message <message>", "Commit message").option("-n, --no-verify", "Skip lint-staged or any other ci checks").option("-p, --push", "Push branch to remote after commit").option("-r, --remote <remote>", "Remote name to push to", "origin").option("-u, --upstream <upstream>", "Upstream branch name (defaults to local branch name)").option("-f, --force", "Force push to remote").option("-k, --keep-branch-on-failure", "Keep the created branch even if operation fails").action(branch);
|
|
14969
|
-
program2.command("multi-branch").description("Create branches for all codeowners").requiredOption("-b, --branch <branch>", "Base branch name (will be suffixed with codeowner name)").requiredOption("-m, --message <message>", "Base commit message (will be suffixed with codeowner name)").option("-n, --no-verify", "Skip lint-staged or any other ci checks").option("-p, --push", "Push branches to remote after commit").option("-r, --remote <remote>", "Remote name to push to", "origin").option("-u, --upstream <upstream>", "Upstream branch name pattern (defaults to local branch name)").option("-f, --force", "Force push to remote").option("-k, --keep-branch-on-failure", "Keep created branches even if operation fails").option("-d, --default-owner <defaultOwner>", "Default owner to use when no codeowners are found for changed files").option("--ignore <patterns>", "Comma-separated patterns to exclude codeowners (e.g., 'team-a,team-b')").option("--include <patterns>", "Comma-separated patterns to include codeowners (e.g., 'team-*,@org/*')").action(multiBranch);
|
|
14979
|
+
program2.command("branch").description("Create new branch with codeowner changes").requiredOption("-o, --owner <owner>", "Code owner name").requiredOption("-b, --branch <branch>", "Branch name").requiredOption("-m, --message <message>", "Commit message").option("-n, --no-verify", "Skip lint-staged or any other ci checks").option("-p, --push", "Push branch to remote after commit").option("-r, --remote <remote>", "Remote name to push to", "origin").option("-u, --upstream <upstream>", "Upstream branch name (defaults to local branch name)").option("-f, --force", "Force push to remote").option("-k, --keep-branch-on-failure", "Keep the created branch even if operation fails").option("--append", "Add commits to existing branch instead of creating a new one").action(branch);
|
|
14980
|
+
program2.command("multi-branch").description("Create branches for all codeowners").requiredOption("-b, --branch <branch>", "Base branch name (will be suffixed with codeowner name)").requiredOption("-m, --message <message>", "Base commit message (will be suffixed with codeowner name)").option("-n, --no-verify", "Skip lint-staged or any other ci checks").option("-p, --push", "Push branches to remote after commit").option("-r, --remote <remote>", "Remote name to push to", "origin").option("-u, --upstream <upstream>", "Upstream branch name pattern (defaults to local branch name)").option("-f, --force", "Force push to remote").option("-k, --keep-branch-on-failure", "Keep created branches even if operation fails").option("-d, --default-owner <defaultOwner>", "Default owner to use when no codeowners are found for changed files").option("--ignore <patterns>", "Comma-separated patterns to exclude codeowners (e.g., 'team-a,team-b')").option("--include <patterns>", "Comma-separated patterns to include codeowners (e.g., 'team-*,@org/*')").option("--append", "Add commits to existing branches instead of creating new ones").action(multiBranch);
|
|
14970
14981
|
program2.parse(process.argv);
|