codeowners-git 1.4.0 → 1.4.2
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/dist/cli.js +23 -19
- package/package.json +3 -2
package/dist/cli.js
CHANGED
|
@@ -14706,10 +14706,13 @@ var getOwner = (filePath) => {
|
|
|
14706
14706
|
const owner = instance.getOwner(filePath);
|
|
14707
14707
|
return owner;
|
|
14708
14708
|
};
|
|
14709
|
-
var getOwnerFiles = async (owner) => {
|
|
14709
|
+
var getOwnerFiles = async (owner, includeUnowned = false) => {
|
|
14710
14710
|
const changedFiles = await getChangedFiles();
|
|
14711
14711
|
return changedFiles.filter((file) => {
|
|
14712
14712
|
const owners = getOwner(file);
|
|
14713
|
+
if (includeUnowned && owners.length === 0) {
|
|
14714
|
+
return true;
|
|
14715
|
+
}
|
|
14713
14716
|
return owners.includes(owner);
|
|
14714
14717
|
});
|
|
14715
14718
|
};
|
|
@@ -14786,7 +14789,7 @@ var branch = async (options) => {
|
|
|
14786
14789
|
log.info("Starting branch creation process...");
|
|
14787
14790
|
originalBranch = await getCurrentBranch();
|
|
14788
14791
|
log.info(`Currently on branch: ${originalBranch}`);
|
|
14789
|
-
filesToCommit = await getOwnerFiles(options.owner);
|
|
14792
|
+
filesToCommit = await getOwnerFiles(options.owner, options.isDefaultOwner || false);
|
|
14790
14793
|
if (filesToCommit.length <= 0) {
|
|
14791
14794
|
log.warn(`No files found for ${options.owner}. Skipping branch creation.`);
|
|
14792
14795
|
return;
|
|
@@ -14869,22 +14872,26 @@ var multiBranch = async (options) => {
|
|
|
14869
14872
|
throw new Error("No changed files found in the repository");
|
|
14870
14873
|
}
|
|
14871
14874
|
const ownerSet = new Set;
|
|
14875
|
+
const filesWithoutOwners = [];
|
|
14872
14876
|
for (const file of changedFiles) {
|
|
14873
14877
|
const owners = getOwner(file);
|
|
14874
|
-
|
|
14875
|
-
|
|
14878
|
+
if (owners.length === 0) {
|
|
14879
|
+
filesWithoutOwners.push(file);
|
|
14880
|
+
} else {
|
|
14881
|
+
for (const owner of owners) {
|
|
14882
|
+
ownerSet.add(owner);
|
|
14883
|
+
}
|
|
14876
14884
|
}
|
|
14877
14885
|
}
|
|
14878
14886
|
let codeowners2 = Array.from(ownerSet);
|
|
14887
|
+
if (filesWithoutOwners.length > 0 && options.defaultOwner) {
|
|
14888
|
+
log.info(`Found ${filesWithoutOwners.length} files without owners. Adding default owner: ${options.defaultOwner}`);
|
|
14889
|
+
codeowners2.push(options.defaultOwner);
|
|
14890
|
+
}
|
|
14879
14891
|
if (codeowners2.length === 0) {
|
|
14880
14892
|
log.warn("No codeowners found for the changed files");
|
|
14881
|
-
|
|
14882
|
-
|
|
14883
|
-
codeowners2.push(options.defaultOwner);
|
|
14884
|
-
} else {
|
|
14885
|
-
log.info("Continuing without creating any branches (use --default-owner to specify a fallback)");
|
|
14886
|
-
return;
|
|
14887
|
-
}
|
|
14893
|
+
log.info("Continuing without creating any branches (use --default-owner to specify a fallback)");
|
|
14894
|
+
return;
|
|
14888
14895
|
} else {
|
|
14889
14896
|
log.info(`Found ${codeowners2.length} codeowners: ${codeowners2.join(", ")}`);
|
|
14890
14897
|
}
|
|
@@ -14924,7 +14931,8 @@ var multiBranch = async (options) => {
|
|
|
14924
14931
|
remote: options.remote,
|
|
14925
14932
|
upstream: options.upstream,
|
|
14926
14933
|
force: options.force,
|
|
14927
|
-
keepBranchOnFailure: options.keepBranchOnFailure
|
|
14934
|
+
keepBranchOnFailure: options.keepBranchOnFailure,
|
|
14935
|
+
isDefaultOwner: owner === options.defaultOwner
|
|
14928
14936
|
});
|
|
14929
14937
|
results.success.push(owner);
|
|
14930
14938
|
} catch (error) {
|
|
@@ -14945,16 +14953,12 @@ var multiBranch = async (options) => {
|
|
|
14945
14953
|
process.exit(1);
|
|
14946
14954
|
}
|
|
14947
14955
|
};
|
|
14956
|
+
// package.json
|
|
14957
|
+
var version = "1.4.2";
|
|
14948
14958
|
|
|
14949
14959
|
// src/commands/version.ts
|
|
14950
|
-
import { readFileSync } from "fs";
|
|
14951
|
-
import { fileURLToPath } from "url";
|
|
14952
|
-
import { dirname, join } from "path";
|
|
14953
14960
|
function getVersion() {
|
|
14954
|
-
|
|
14955
|
-
const __dirname2 = dirname(__filename2);
|
|
14956
|
-
const packageJson = JSON.parse(readFileSync(join(__dirname2, "../../package.json"), "utf8"));
|
|
14957
|
-
return packageJson.version;
|
|
14961
|
+
return version;
|
|
14958
14962
|
}
|
|
14959
14963
|
|
|
14960
14964
|
// src/cli.ts
|
package/package.json
CHANGED