forked from axios/axios
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #216 from axios/v1.x
Create a new pull request by comparing changes across two branches
- Loading branch information
Showing
26 changed files
with
1,243 additions
and
1,035 deletions.
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
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
Large diffs are not rendered by default.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import util from "util"; | ||
import cp from "child_process"; | ||
|
||
export const exec = util.promisify(cp.exec); | ||
|
||
export const getBlobSize = async (filepath, sha ='HEAD') => { | ||
const size = (await exec( | ||
`git cat-file -s ${sha}:${filepath}` | ||
)).stdout; | ||
|
||
return size ? +size : 0; | ||
} | ||
|
||
export const getBlobHistory = async (filepath, maxCount= 5) => { | ||
const log = (await exec( | ||
`git log --max-count=${maxCount} --no-walk --tags=v* --oneline --format=%H%d -- ${filepath}` | ||
)).stdout; | ||
|
||
const commits = []; | ||
|
||
let match; | ||
|
||
const regexp = /^(\w+) \(tag: (v?[.\d]+)\)$/gm; | ||
|
||
while((match = regexp.exec(log))) { | ||
commits.push({ | ||
sha: match[1], | ||
tag: match[2], | ||
size: await getBlobSize(filepath, match[1]) | ||
}) | ||
} | ||
|
||
return commits; | ||
} | ||
|
||
export const getTags = async (pattern = 'v*', sort = '-v:refname') => { | ||
const log = (await exec( | ||
`git tag -l ${pattern} --sort=${sort}` | ||
)).stdout; | ||
|
||
return log.split(/\r?\n/); | ||
} |
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,18 @@ | ||
import {exec, getTags} from "./repo.js"; | ||
import fs from "fs"; | ||
import {colorize} from "./helpers/colorize.js"; | ||
|
||
const {version} = JSON.parse(fs.readFileSync('./package.json')); | ||
|
||
const [major] = version.split('.'); | ||
const tags = await getTags(); | ||
const latestTag = (tags[0] || '').replace(/^v/, ''); | ||
|
||
const isBeta = !/^v?(\d+).(\d)+.(\d)+$/.test(version); | ||
const isLatest = latestTag === version; | ||
|
||
let tag = isBeta ? 'next' : isLatest ? 'latest' : `v${major}`; | ||
|
||
console.log(colorize()`Version [${version}] [${isBeta ? 'prerelease' : 'release'}] latest [${latestTag}]=> NPM Tag [${tag}]`); | ||
|
||
await exec(`echo "tag=${tag}" >> $GITHUB_OUTPUT`); |
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.