Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
6fae5287
V
vscode
项目概览
掘金者说
/
vscode
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
V
vscode
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
6fae5287
编写于
7月 08, 2018
作者:
R
Rob Lourens
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix #53445 - change build id generation to not depend on git tags
上级
3d358011
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
18 addition
and
263 deletion
+18
-263
build/gulpfile.vscode.js
build/gulpfile.vscode.js
+18
-10
build/lib/test/util.test.js
build/lib/test/util.test.js
+0
-56
build/lib/test/util.test.ts
build/lib/test/util.test.ts
+0
-79
build/lib/util.js
build/lib/util.js
+0
-57
build/lib/util.ts
build/lib/util.ts
+0
-61
未找到文件。
build/gulpfile.vscode.js
浏览文件 @
6fae5287
...
...
@@ -271,10 +271,8 @@ function packageTask(platform, arch, opts) {
const
date
=
new
Date
().
toISOString
();
const
productJsonUpdate
=
{
commit
,
date
,
checksums
};
try
{
if
(
shouldSetupSettingsSearch
())
{
productJsonUpdate
.
settingsSearchBuildId
=
getSettingsSearchBuildId
(
packageJson
);
}
catch
(
err
)
{
console
.
warn
(
err
);
}
const
productJsonStream
=
gulp
.
src
([
'
product.json
'
],
{
base
:
'
.
'
})
...
...
@@ -474,9 +472,8 @@ gulp.task('upload-vscode-sourcemaps', ['minify-vscode'], () => {
const
allConfigDetailsPath
=
path
.
join
(
os
.
tmpdir
(),
'
configuration.json
'
);
gulp
.
task
(
'
upload-vscode-configuration
'
,
[
'
generate-vscode-configuration
'
],
()
=>
{
const
branch
=
process
.
env
.
BUILD_SOURCEBRANCH
;
if
(
!
/
\/
master$/
.
test
(
branch
)
&&
branch
.
indexOf
(
'
/release/
'
)
<
0
)
{
if
(
!
shouldSetupSettingsSearch
())
{
const
branch
=
process
.
env
.
BUILD_SOURCEBRANCH
;
console
.
log
(
`Only runs on master and release branches, not
${
branch
}
`
);
return
;
}
...
...
@@ -499,13 +496,24 @@ gulp.task('upload-vscode-configuration', ['generate-vscode-configuration'], () =
}));
});
function
getSettingsSearchBuildId
(
packageJson
)
{
const
previous
=
util
.
getPreviousVersion
(
packageJson
.
version
);
function
shouldSetupSettingsSearch
()
{
const
branch
=
process
.
env
.
BUILD_SOURCEBRANCH
;
return
branch
&&
(
/
\/
master$/
.
test
(
branch
)
||
branch
.
indexOf
(
'
/release/
'
)
>=
0
);
}
function
getSettingsSearchBuildId
(
packageJson
)
{
try
{
const
out
=
cp
.
execSync
(
`git rev-list
${
previous
}
..HEAD --count`
);
const
branch
=
process
.
env
.
BUILD_SOURCEBRANCH
;
const
branchId
=
branch
.
indexOf
(
'
/release/
'
)
>=
0
?
0
:
/
\/
master$/
.
test
(
branch
)
?
1
:
2
;
// Some unexpected branch
const
out
=
cp
.
execSync
(
`git rev-list master --count`
);
const
count
=
parseInt
(
out
.
toString
());
return
util
.
versionStringToNumber
(
packageJson
.
version
)
*
1
e4
+
count
;
// <version number><commit count><branchId (avoid unlikely conflicts)>
// 1.25.1, 1,234,567 commits, master = 1250112345671
return
util
.
versionStringToNumber
(
packageJson
.
version
)
*
1
e8
+
count
*
10
+
branchId
;
}
catch
(
e
)
{
throw
new
Error
(
'
Could not determine build number:
'
+
e
.
toString
());
}
...
...
build/lib/test/util.test.js
已删除
100644 → 0
浏览文件 @
3d358011
"
use strict
"
;
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
Object
.
defineProperty
(
exports
,
"
__esModule
"
,
{
value
:
true
});
var
assert
=
require
(
"
assert
"
);
var
util
=
require
(
"
../util
"
);
function
getMockTagExists
(
tags
)
{
return
function
(
tag
)
{
return
tags
.
indexOf
(
tag
)
>=
0
;
};
}
suite
(
'
util tests
'
,
function
()
{
test
(
'
getPreviousVersion - patch
'
,
function
()
{
assert
.
equal
(
util
.
getPreviousVersion
(
'
1.2.3
'
,
getMockTagExists
([
'
1.2.2
'
,
'
1.2.1
'
,
'
1.2.0
'
,
'
1.1.0
'
])),
'
1.2.2
'
);
});
test
(
'
getPreviousVersion - patch invalid
'
,
function
()
{
try
{
util
.
getPreviousVersion
(
'
1.2.2
'
,
getMockTagExists
([
'
1.2.0
'
,
'
1.1.0
'
]));
}
catch
(
e
)
{
// expected
return
;
}
throw
new
Error
(
'
Expected an exception
'
);
});
test
(
'
getPreviousVersion - minor
'
,
function
()
{
assert
.
equal
(
util
.
getPreviousVersion
(
'
1.2.0
'
,
getMockTagExists
([
'
1.1.0
'
,
'
1.1.1
'
,
'
1.1.2
'
,
'
1.1.3
'
])),
'
1.1.3
'
);
assert
.
equal
(
util
.
getPreviousVersion
(
'
1.2.0
'
,
getMockTagExists
([
'
1.1.0
'
,
'
1.0.0
'
])),
'
1.1.0
'
);
});
test
(
'
getPreviousVersion - minor gap
'
,
function
()
{
assert
.
equal
(
util
.
getPreviousVersion
(
'
1.2.0
'
,
getMockTagExists
([
'
1.1.0
'
,
'
1.1.1
'
,
'
1.1.3
'
])),
'
1.1.1
'
);
});
test
(
'
getPreviousVersion - minor invalid
'
,
function
()
{
try
{
util
.
getPreviousVersion
(
'
1.2.0
'
,
getMockTagExists
([
'
1.0.0
'
]));
}
catch
(
e
)
{
// expected
return
;
}
throw
new
Error
(
'
Expected an exception
'
);
});
test
(
'
getPreviousVersion - major
'
,
function
()
{
assert
.
equal
(
util
.
getPreviousVersion
(
'
2.0.0
'
,
getMockTagExists
([
'
1.0.0
'
,
'
1.1.0
'
,
'
1.2.0
'
,
'
1.2.1
'
,
'
1.2.2
'
])),
'
1.2.2
'
);
});
test
(
'
getPreviousVersion - major invalid
'
,
function
()
{
try
{
util
.
getPreviousVersion
(
'
3.0.0
'
,
getMockTagExists
([
'
1.0.0
'
]));
}
catch
(
e
)
{
// expected
return
;
}
throw
new
Error
(
'
Expected an exception
'
);
});
});
build/lib/test/util.test.ts
已删除
100644 → 0
浏览文件 @
3d358011
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import
assert
=
require
(
'
assert
'
);
import
util
=
require
(
'
../util
'
);
function
getMockTagExists
(
tags
:
string
[])
{
return
(
tag
:
string
)
=>
tags
.
indexOf
(
tag
)
>=
0
;
}
suite
(
'
util tests
'
,
()
=>
{
test
(
'
getPreviousVersion - patch
'
,
()
=>
{
assert
.
equal
(
util
.
getPreviousVersion
(
'
1.2.3
'
,
getMockTagExists
([
'
1.2.2
'
,
'
1.2.1
'
,
'
1.2.0
'
,
'
1.1.0
'
])),
'
1.2.2
'
);
});
test
(
'
getPreviousVersion - patch invalid
'
,
()
=>
{
try
{
util
.
getPreviousVersion
(
'
1.2.2
'
,
getMockTagExists
([
'
1.2.0
'
,
'
1.1.0
'
]));
}
catch
(
e
)
{
// expected
return
;
}
throw
new
Error
(
'
Expected an exception
'
);
});
test
(
'
getPreviousVersion - minor
'
,
()
=>
{
assert
.
equal
(
util
.
getPreviousVersion
(
'
1.2.0
'
,
getMockTagExists
([
'
1.1.0
'
,
'
1.1.1
'
,
'
1.1.2
'
,
'
1.1.3
'
])),
'
1.1.3
'
);
assert
.
equal
(
util
.
getPreviousVersion
(
'
1.2.0
'
,
getMockTagExists
([
'
1.1.0
'
,
'
1.0.0
'
])),
'
1.1.0
'
);
});
test
(
'
getPreviousVersion - minor gap
'
,
()
=>
{
assert
.
equal
(
util
.
getPreviousVersion
(
'
1.2.0
'
,
getMockTagExists
([
'
1.1.0
'
,
'
1.1.1
'
,
'
1.1.3
'
])),
'
1.1.1
'
);
});
test
(
'
getPreviousVersion - minor invalid
'
,
()
=>
{
try
{
util
.
getPreviousVersion
(
'
1.2.0
'
,
getMockTagExists
([
'
1.0.0
'
]));
}
catch
(
e
)
{
// expected
return
;
}
throw
new
Error
(
'
Expected an exception
'
);
});
test
(
'
getPreviousVersion - major
'
,
()
=>
{
assert
.
equal
(
util
.
getPreviousVersion
(
'
2.0.0
'
,
getMockTagExists
([
'
1.0.0
'
,
'
1.1.0
'
,
'
1.2.0
'
,
'
1.2.1
'
,
'
1.2.2
'
])),
'
1.2.2
'
);
});
test
(
'
getPreviousVersion - major invalid
'
,
()
=>
{
try
{
util
.
getPreviousVersion
(
'
3.0.0
'
,
getMockTagExists
([
'
1.0.0
'
]));
}
catch
(
e
)
{
// expected
return
;
}
throw
new
Error
(
'
Expected an exception
'
);
});
});
build/lib/util.js
浏览文件 @
6fae5287
...
...
@@ -14,7 +14,6 @@ var fs = require("fs");
var
_rimraf
=
require
(
"
rimraf
"
);
var
git
=
require
(
"
./git
"
);
var
VinylFile
=
require
(
"
vinyl
"
);
var
cp
=
require
(
"
child_process
"
);
var
NoCancellationToken
=
{
isCancellationRequested
:
function
()
{
return
false
;
}
};
function
incremental
(
streamProvider
,
initial
,
supportsCancellation
)
{
var
input
=
es
.
through
();
...
...
@@ -211,62 +210,6 @@ function filter(fn) {
return
result
;
}
exports
.
filter
=
filter
;
function
tagExists
(
tagName
)
{
try
{
cp
.
execSync
(
"
git rev-parse
"
+
tagName
,
{
stdio
:
'
ignore
'
});
return
true
;
}
catch
(
e
)
{
return
false
;
}
}
/**
* Returns the version previous to the given version. Throws if a git tag for that version doesn't exist.
* Given 1.17.2, return 1.17.1
* 1.18.0 => 1.17.2. (or the highest 1.17.x)
* 2.0.0 => 1.18.0 (or the highest 1.x)
*/
function
getPreviousVersion
(
versionStr
,
_tagExists
)
{
if
(
_tagExists
===
void
0
)
{
_tagExists
=
tagExists
;
}
function
getLatestTagFromBase
(
semverArr
,
componentToTest
)
{
var
baseVersion
=
semverArr
.
join
(
'
.
'
);
if
(
!
_tagExists
(
baseVersion
))
{
throw
new
Error
(
'
Failed to find git tag for base version,
'
+
baseVersion
);
}
var
goodTag
;
do
{
goodTag
=
semverArr
.
join
(
'
.
'
);
semverArr
[
componentToTest
]
++
;
}
while
(
_tagExists
(
semverArr
.
join
(
'
.
'
)));
return
goodTag
;
}
var
semverArr
=
versionStringToNumberArray
(
versionStr
);
if
(
semverArr
[
2
]
>
0
)
{
semverArr
[
2
]
--
;
var
previous
=
semverArr
.
join
(
'
.
'
);
if
(
!
_tagExists
(
previous
))
{
throw
new
Error
(
'
Failed to find git tag for previous version,
'
+
previous
);
}
return
previous
;
}
else
if
(
semverArr
[
1
]
>
0
)
{
semverArr
[
1
]
--
;
return
getLatestTagFromBase
(
semverArr
,
2
);
}
else
{
semverArr
[
0
]
--
;
// Find 1.x.0 for latest x
var
latestMinorVersion
=
getLatestTagFromBase
(
semverArr
,
1
);
// Find 1.x.y for latest y
return
getLatestTagFromBase
(
versionStringToNumberArray
(
latestMinorVersion
),
2
);
}
}
exports
.
getPreviousVersion
=
getPreviousVersion
;
function
versionStringToNumberArray
(
versionStr
)
{
return
versionStr
.
split
(
'
.
'
)
.
map
(
function
(
s
)
{
return
parseInt
(
s
);
});
}
function
versionStringToNumber
(
versionStr
)
{
var
semverRegex
=
/
(\d
+
)\.(\d
+
)\.(\d
+
)
/
;
var
match
=
versionStr
.
match
(
semverRegex
);
...
...
build/lib/util.ts
浏览文件 @
6fae5287
...
...
@@ -17,7 +17,6 @@ import * as git from './git';
import
*
as
VinylFile
from
'
vinyl
'
;
import
{
ThroughStream
}
from
'
through
'
;
import
*
as
sm
from
'
source-map
'
;
import
*
as
cp
from
'
child_process
'
;
export
interface
ICancellationToken
{
isCancellationRequested
():
boolean
;
...
...
@@ -271,66 +270,6 @@ export function filter(fn: (data: any) => boolean): FilterStream {
return
result
;
}
function
tagExists
(
tagName
:
string
):
boolean
{
try
{
cp
.
execSync
(
`git rev-parse
${
tagName
}
`
,
{
stdio
:
'
ignore
'
});
return
true
;
}
catch
(
e
)
{
return
false
;
}
}
/**
* Returns the version previous to the given version. Throws if a git tag for that version doesn't exist.
* Given 1.17.2, return 1.17.1
* 1.18.0 => 1.17.2. (or the highest 1.17.x)
* 2.0.0 => 1.18.0 (or the highest 1.x)
*/
export
function
getPreviousVersion
(
versionStr
:
string
,
_tagExists
=
tagExists
)
{
function
getLatestTagFromBase
(
semverArr
:
number
[],
componentToTest
:
number
):
string
{
const
baseVersion
=
semverArr
.
join
(
'
.
'
);
if
(
!
_tagExists
(
baseVersion
))
{
throw
new
Error
(
'
Failed to find git tag for base version,
'
+
baseVersion
);
}
let
goodTag
;
do
{
goodTag
=
semverArr
.
join
(
'
.
'
);
semverArr
[
componentToTest
]
++
;
}
while
(
_tagExists
(
semverArr
.
join
(
'
.
'
)));
return
goodTag
;
}
const
semverArr
=
versionStringToNumberArray
(
versionStr
);
if
(
semverArr
[
2
]
>
0
)
{
semverArr
[
2
]
--
;
const
previous
=
semverArr
.
join
(
'
.
'
);
if
(
!
_tagExists
(
previous
))
{
throw
new
Error
(
'
Failed to find git tag for previous version,
'
+
previous
);
}
return
previous
;
}
else
if
(
semverArr
[
1
]
>
0
)
{
semverArr
[
1
]
--
;
return
getLatestTagFromBase
(
semverArr
,
2
);
}
else
{
semverArr
[
0
]
--
;
// Find 1.x.0 for latest x
const
latestMinorVersion
=
getLatestTagFromBase
(
semverArr
,
1
);
// Find 1.x.y for latest y
return
getLatestTagFromBase
(
versionStringToNumberArray
(
latestMinorVersion
),
2
);
}
}
function
versionStringToNumberArray
(
versionStr
:
string
):
number
[]
{
return
versionStr
.
split
(
'
.
'
)
.
map
(
s
=>
parseInt
(
s
));
}
export
function
versionStringToNumber
(
versionStr
:
string
)
{
const
semverRegex
=
/
(\d
+
)\.(\d
+
)\.(\d
+
)
/
;
const
match
=
versionStr
.
match
(
semverRegex
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录