Skip to content

Commit

Permalink
remove some old function
Browse files Browse the repository at this point in the history
  • Loading branch information
saqqdy committed Nov 26, 2021
1 parent 9553058 commit 3a5fd62
Show file tree
Hide file tree
Showing 30 changed files with 62 additions and 240 deletions.
4 changes: 2 additions & 2 deletions app/socket/gitmars.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ let glob = {}, config = {}, branch = [], current = '', interval = null;
*/
const getData = (socket, option) => {
delete require.cache[require.resolve('../../lib/core/global')];
delete require.cache[require.resolve('../../lib/core/config')];
delete require.cache[require.resolve('../../lib/core/getConfig')];
const g = require('../../lib/core/global');
const c = require('../../lib/core/config');
const c = require('../../lib/core/getConfig')();
const bh = searchBranches({ path: option.cwd || home });
const cur = getCurrentBranch({ path: option.cwd || home });
if (!glob || JSON.stringify(glob) !== JSON.stringify(g)) {
Expand Down

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion app/www/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
<div id="box"></div>

<script nomodule>!function(){var e=document,t=e.createElement("script");if(!("noModule"in t)&&"onbeforeload"in t){var n=!1;e.addEventListener("beforeload",(function(e){if(e.target===t)n=!0;else if(!e.target.hasAttribute("nomodule")||!n)return;e.preventDefault()}),!0),t.type="module",t.src=".",e.head.appendChild(t),t.remove()}}();</script>
<script nomodule id="vite-legacy-polyfill" src="/assets/polyfills-legacy.d077bd19.js"></script>
<script nomodule id="vite-legacy-polyfill" src="/assets/polyfills-legacy.32b08e0b.js"></script>
<script nomodule id="vite-legacy-entry" data-src="/assets/index-legacy.faea7a16.js">System.import(document.getElementById('vite-legacy-entry').getAttribute('data-src'))</script>
</body>
</html>
20 changes: 0 additions & 20 deletions bin/core/checkBranch.ts

This file was deleted.

42 changes: 0 additions & 42 deletions bin/core/config.ts

This file was deleted.

19 changes: 0 additions & 19 deletions bin/core/configFrom.ts

This file was deleted.

2 changes: 1 addition & 1 deletion bin/core/git/getBranchesFromID.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ function getBranchesFromID(commitID: string, remote = false): string[] {
} --contains ${commitID} --format="%(refname:short)`,
{ silent: true }
)
.stdout.replace(/(^\s+|\n*$)/g, '') // 去除首尾
.stdout.replace(/(^\s+|\n+$)/, '') // 去除首尾
return out ? out.split('\n') : []
}

Expand Down
2 changes: 1 addition & 1 deletion bin/core/git/getGitStatus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ function getGitStatus(config: any = {}): GitStatusInfoType {
const { silent = true } = config
const out = sh
.exec('git status -s --no-column', { silent })
.stdout.replace(/(^\s+|\n*$)/g, '') // 去除首尾
.stdout.replace(/(^\s+|\n+$)/, '') // 去除首尾
const list = out ? out.replace(/\n(\s+)/g, '\n').split('\n') : []
const sum: GitStatusInfoType = {
A: [],
Expand Down
4 changes: 2 additions & 2 deletions bin/core/git/getGitUser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const sh = require('shelljs')
function getGitUser(): string {
return sh
.exec('git config user.name', { silent: true })
.stdout.replace(/(^\s+|\n*$)/g, '') // 去除首尾
.stdout.replace(/(^\s+|\n+$)/, '') // 去除首尾
}

/**
Expand All @@ -19,7 +19,7 @@ function getGitUser(): string {
function getGitEmail(): string {
return sh
.exec('git config user.email', { silent: true })
.stdout.replace(/(^\s+|\n*$)/g, '') // 去除首尾
.stdout.replace(/(^\s+|\n+$)/, '') // 去除首尾
}

module.exports = {
Expand Down
9 changes: 5 additions & 4 deletions bin/core/getStashList.ts → bin/core/git/getStashList.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
const sh = require('shelljs')
const { queue } = require('./queue')
const { warning } = require('./utils/colors')
const { warning } = require('../utils/colors')

/**
* 获取暂存区列表
*
* @param key - 名称
* @returns stashList - 返回stashList
*/
async function getStashList(key: string) {
const data = (await queue(['git stash list']))[0].out.replace(/^\*\s+/, '')
function getStashList(key: string) {
const data = sh
.exec('git stash list', { silent: true })
.stdout.replace(/(^\s+|\n+$)/, '')
const list: string[] = (data && data.split('\n')) || []
const arr: {
key: string
Expand Down
4 changes: 3 additions & 1 deletion bin/core/git/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const getGitStatus = require('./getGitStatus')
const getCommandMessage = require('./getCommandMessage')
const checkGitStatus = require('./checkGitStatus')
const filterBranch = require('./filterBranch')
const getStashList = require('./getStashList')

module.exports = {
getIsGitProject,
Expand All @@ -38,6 +39,7 @@ module.exports = {
getGitStatus,
getCommandMessage,
checkGitStatus,
filterBranch
filterBranch,
getStashList
}
export {}
31 changes: 0 additions & 31 deletions bin/core/searchBranch.ts

This file was deleted.

8 changes: 4 additions & 4 deletions bin/gitm-admin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const { create, publish, update, clean } = require('./conf/admin')
const { getUserToken } = require('./core/api/index')
const { getType } = require('js-cool')
const { queue } = require('./core/queue')
const checkBranch = require('./core/checkBranch')
const { getIsBranchOrCommitExist } = require('./core/git/index')
const {
getIsGitProject,
getCurrentBranch,
Expand Down Expand Up @@ -70,12 +70,12 @@ if (create.args.length > 0) {
_program.option(o.flags, o.description, o.defaultValue)
})
// .command('create <type>')
_program.action(async (type: string): Promise<void> => {
_program.action((type: string): void => {
const opts = ['bugfix', 'release', 'develop', 'support'] // 允许执行的指令
const base: string = type === 'release' ? config.master : config.release
const status = checkGitStatus()
const hasBase = await checkBranch(base)
const exits = await checkBranch(config[type])
const hasBase = getIsBranchOrCommitExist(base)
const exits = getIsBranchOrCommitExist(config[type])
if (!status) sh.exit(1)
if (!hasBase) {
sh.echo(error(base + '分支不存在,请先创建' + base + '分支'))
Expand Down
6 changes: 3 additions & 3 deletions bin/gitm-combine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ const sh = require('shelljs')
const { options, args } = require('./conf/combine')
const { getType } = require('js-cool')
const { queue } = require('./core/queue')
const searchBranch = require('./core/searchBranch')
const {
getIsGitProject,
getCurrentBranch,
getGitConfig,
getIsMergedTargetBranch,
getIsUpdatedInTime,
checkGitStatus
checkGitStatus,
searchBranches
} = require('./core/git/index')
const { error, warning, createArgs } = require('./core/utils/index')
const { getCurlOfMergeRequest } = require('./core/shell/index')
Expand Down Expand Up @@ -121,7 +121,7 @@ program.action(
sh.echo('请输入分支名称')
sh.exit(1)
}
const branches = await searchBranch(type)
const branches = searchBranches({ type })
if (branches.length === 1) {
;[type, _nameArr] = branches[0].split('/')
name = _nameArr.join('/')
Expand Down
6 changes: 3 additions & 3 deletions bin/gitm-end.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ const sh = require('shelljs')
const { options, args } = require('./conf/end')
const { getType } = require('js-cool')
const { queue } = require('./core/queue')
const searchBranch = require('./core/searchBranch')
const {
getIsGitProject,
getCurrentBranch,
getGitConfig,
getIsMergedTargetBranch,
getIsBranchOrCommitExist,
checkGitStatus
checkGitStatus,
searchBranches
} = require('./core/git/index')
const { error, createArgs } = require('./core/utils/index')
const { getCurlOfMergeRequest } = require('./core/shell/index')
Expand Down Expand Up @@ -104,7 +104,7 @@ program.action(
sh.echo('请输入分支名称')
sh.exit(1)
}
const branches = await searchBranch(type)
const branches = searchBranches({ type })
if (branches.length === 1) {
;[type, ..._nameArr] = branches[0].split('/')
name = _nameArr.join('/')
Expand Down
11 changes: 7 additions & 4 deletions bin/gitm-get.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@ const { program } = require('commander')
const sh = require('shelljs')
const { options, args } = require('./conf/get')
const { queue } = require('./core/queue')
const getStashList = require('./core/getStashList')
const { getIsGitProject, getCurrentBranch } = require('./core/git/index')
const {
getIsGitProject,
getCurrentBranch,
getStashList
} = require('./core/git/index')
const { error, warning, createArgs } = require('./core/utils/index')
if (!getIsGitProject()) {
sh.echo(error('当前目录不是git项目目录'))
Expand All @@ -29,9 +32,9 @@ options.forEach((o: GitmarsOptionOptionsType) => {
program.option(o.flags, o.description, o.defaultValue)
})
// .option('-k, --keep [keep]', '保留暂存区不删除', false)
program.action(async (message: string, index: string, opt: GitmBuildOption) => {
program.action((message: string, index: string, opt: GitmBuildOption) => {
if (!message) message = getCurrentBranch()
const list = await getStashList(message)
const list = getStashList(message)
if (list.length === 0) {
sh.echo(warning('该分支没有暂存任何文件!'))
sh.exit(0)
Expand Down
8 changes: 0 additions & 8 deletions lib/core/checkBranch.js

This file was deleted.

42 changes: 0 additions & 42 deletions lib/core/config.js

This file was deleted.

14 changes: 0 additions & 14 deletions lib/core/configFrom.js

This file was deleted.

2 changes: 1 addition & 1 deletion lib/core/git/getBranchesFromID.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

const sh = require("shelljs");
function getBranchesFromID(commitID, remote = false) {
const out = sh.exec(`git branch ${remote ? "-r" : ""} --contains ${commitID} --format="%(refname:short)`, { silent: true }).stdout.replace(/(^\s+|\n*$)/g, "");
const out = sh.exec(`git branch ${remote ? "-r" : ""} --contains ${commitID} --format="%(refname:short)`, { silent: true }).stdout.replace(/(^\s+|\n+$)/, "");
return out ? out.split("\n") : [];
}
module.exports = getBranchesFromID;
2 changes: 1 addition & 1 deletion lib/core/git/getGitStatus.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
const sh = require("shelljs");
function getGitStatus(config = {}) {
const { silent = true } = config;
const out = sh.exec("git status -s --no-column", { silent }).stdout.replace(/(^\s+|\n*$)/g, "");
const out = sh.exec("git status -s --no-column", { silent }).stdout.replace(/(^\s+|\n+$)/, "");
const list = out ? out.replace(/\n(\s+)/g, "\n").split("\n") : [];
const sum = {
A: [],
Expand Down
Loading

1 comment on commit 3a5fd62

@vercel
Copy link

@vercel vercel bot commented on 3a5fd62 Nov 26, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.