mirror of
https://code.forgejo.org/actions/upload-artifact.git
synced 2025-05-25 02:14:45 +00:00
PR feedback
This commit is contained in:
parent
cfc46d10b1
commit
9ee6dab9c2
3 changed files with 16 additions and 16 deletions
14
dist/index.js
vendored
14
dist/index.js
vendored
|
@ -6251,7 +6251,7 @@ function getMultiPathLCA(searchPaths) {
|
|||
// split each of the search paths using the platform specific separator
|
||||
for (const searchPath of searchPaths) {
|
||||
core_1.debug(`Using search path ${searchPath}`);
|
||||
const splitSearchPath = searchPath.split(path.sep);
|
||||
const splitSearchPath = path.normalize(searchPath).split(path.sep);
|
||||
// keep track of the smallest path length so that we don't accidentally later go out of bounds
|
||||
smallestPathLength = Math.min(smallestPathLength, splitSearchPath.length);
|
||||
splitPaths.push(splitSearchPath);
|
||||
|
@ -6263,21 +6263,21 @@ function getMultiPathLCA(searchPaths) {
|
|||
let splitIndex = 0;
|
||||
// function to check if the paths are the same at a specific index
|
||||
function isPathTheSame() {
|
||||
const common = splitPaths[0][splitIndex];
|
||||
const compare = splitPaths[0][splitIndex];
|
||||
for (let i = 1; i < splitPaths.length; i++) {
|
||||
if (common !== splitPaths[i][splitIndex]) {
|
||||
if (compare !== splitPaths[i][splitIndex]) {
|
||||
// a non-common index has been reached
|
||||
return false;
|
||||
}
|
||||
}
|
||||
// if all are the same, add to the end result & increment the index
|
||||
commonPaths.push(common);
|
||||
splitIndex++;
|
||||
return true;
|
||||
}
|
||||
// Loop over all the search paths until there is a non-common ancestor or we go out of bounds
|
||||
while (splitIndex < smallestPathLength) {
|
||||
if (!isPathTheSame()) {
|
||||
// if all are the same, add to the end result & increment the index
|
||||
commonPaths.push(splitPaths[0][splitIndex]);
|
||||
splitIndex++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -6306,7 +6306,7 @@ function findFilesToUpload(searchPath, globOptions) {
|
|||
if (searchPaths.length > 1) {
|
||||
core_1.info(`Multiple search paths detected. Calculating the least common ancestor of all paths`);
|
||||
const lcaSearchPath = getMultiPathLCA(searchPaths);
|
||||
core_1.info(`The least common ancestor is ${lcaSearchPath} This will be the root directory of the artifact`);
|
||||
core_1.info(`The least common ancestor is ${lcaSearchPath}. This will be the root directory of the artifact`);
|
||||
return {
|
||||
filesToUpload: searchResults,
|
||||
rootDirectory: lcaSearchPath
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue