Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleDetection
提交
982d4230
P
PaddleDetection
项目概览
PaddlePaddle
/
PaddleDetection
大约 1 年 前同步成功
通知
695
Star
11112
Fork
2696
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
184
列表
看板
标记
里程碑
合并请求
40
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
PaddleDetection
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
184
Issue
184
列表
看板
标记
里程碑
合并请求
40
合并请求
40
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
982d4230
编写于
7月 19, 2018
作者:
Q
Qiyang Min
提交者:
GitHub
7月 19, 2018
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #12145 from velconia/update_version_via_branch_name
Update version via branch name
上级
a188b03f
3e30d401
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
78 addition
and
13 deletion
+78
-13
cmake/version.cmake
cmake/version.cmake
+30
-13
python/paddle/fluid/tests/unittests/test_version.py
python/paddle/fluid/tests/unittests/test_version.py
+48
-0
未找到文件。
cmake/version.cmake
浏览文件 @
982d4230
...
...
@@ -4,6 +4,14 @@ set(tmp_version "HEAD")
set
(
TAG_VERSION_REGEX
"[0-9]+
\\
.[0-9]+
\\
.[0-9]+(
\\
.(a|b|rc)
\\
.[0-9]+)?"
)
set
(
COMMIT_VERSION_REGEX
"[0-9a-f]+[0-9a-f]+[0-9a-f]+[0-9a-f]+[0-9a-f]+"
)
while
(
"
${
PADDLE_VERSION
}
"
STREQUAL
""
)
# Check current branch name
execute_process
(
COMMAND
${
GIT_EXECUTABLE
}
rev-parse --abbrev-ref
${
tmp_version
}
WORKING_DIRECTORY
${
PADDLE_SOURCE_DIR
}
OUTPUT_VARIABLE GIT_BRANCH_NAME
RESULT_VARIABLE GIT_BRANCH_RESULT
ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE
)
if
(
NOT
${
GIT_BRANCH_RESULT
}
)
execute_process
(
COMMAND
${
GIT_EXECUTABLE
}
describe --tags --abbrev=0 --always
${
tmp_version
}
WORKING_DIRECTORY
${
PADDLE_SOURCE_DIR
}
...
...
@@ -11,6 +19,8 @@ while ("${PADDLE_VERSION}" STREQUAL "")
RESULT_VARIABLE GIT_RESULT
ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE
)
if
(
NOT
${
GIT_RESULT
}
)
# Check if current branch is release branch
if
(
${
GIT_BRANCH_NAME
}
MATCHES
"release/
${
TAG_VERSION_REGEX
}
"
)
# Check the tag is a correct version
if
(
${
GIT_TAG_NAME
}
MATCHES
"
${
COMMIT_VERSION_REGEX
}
"
)
# if no tag was found, set PADDLE_VERSION to latest
...
...
@@ -20,10 +30,17 @@ while ("${PADDLE_VERSION}" STREQUAL "")
else
()
# otherwise, get the previous git tag name.
set
(
tmp_version
"
${
GIT_TAG_NAME
}
~1"
)
endif
()
else
()
# otherwise, we always set PADDLE_VERSION to latest
set
(
PADDLE_VERSION
"latest"
)
endif
()
else
()
set
(
PADDLE_VERSION
"0.0.0"
)
message
(
WARNING
"Cannot add paddle version from git tag"
)
endif
()
else
()
set
(
PADDLE_VERSION
"0.0.0"
)
message
(
WARNING
"Cannot add paddle version for wrong git branch result"
)
endif
()
endwhile
()
add_definitions
(
-DPADDLE_VERSION=
${
PADDLE_VERSION
}
)
...
...
python/paddle/fluid/tests/unittests/test_version.py
0 → 100644
浏览文件 @
982d4230
# Copyright (c) 2018 PaddlePaddle Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import
unittest
import
re
import
paddle.version
as
fluid_version
class
VersionTest
(
unittest
.
TestCase
):
def
setUp
(
self
):
self
.
_major_regex
=
"[0-9]+"
self
.
_minor_regex
=
"[0-9]+"
self
.
_patch_regex
=
"[0-9]+(
\\
.(a|b|rc)
\\
.[0-9]+)?"
self
.
_rc_regex
=
"[0-9]+"
self
.
_version_regex
=
"[0-9]+
\\
.[0-9]+
\\
.[0-9]+(
\\
.(a|b|rc)
\\
.[0-9]+)?"
self
.
_commit_regex
=
"[0-9a-f]{5,49}"
def
test_check_output
(
self
):
# check commit format
self
.
assertTrue
(
re
.
match
(
self
.
_commit_regex
,
fluid_version
.
commit
))
self
.
assertTrue
(
isinstance
(
fluid_version
.
istaged
,
bool
))
# check version format
if
fluid_version
.
istaged
:
self
.
assertEqual
(
fluid_version
.
major
,
0
)
self
.
assertEqual
(
fluid_version
.
minor
,
0
)
self
.
assertEqual
(
fluid_version
.
patch
,
"0"
)
self
.
assertEqual
(
fluid_version
.
rc
,
0
)
self
.
assertEqual
(
fluid_version
.
full_version
,
"0.0.0"
)
else
:
self
.
assertTrue
(
re
.
match
(
self
.
_major_regex
,
fluid_version
.
major
))
self
.
assertTrue
(
re
.
match
(
self
.
_minor_regex
,
fluid_version
.
minor
))
self
.
assertTrue
(
re
.
match
(
self
.
_patch_regex
,
fluid_version
.
patch
))
self
.
assertTrue
(
re
.
match
(
self
.
_rc_regex
,
fluid_version
.
rc
))
self
.
assertTrue
(
re
.
match
(
self
.
_version_regex
,
fluid_version
.
full_version
))
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录