Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
github
hub
提交
4f0312f3
H
hub
项目概览
github
/
hub
10 个月 前同步成功
通知
3
Star
22523
Fork
2406
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
H
hub
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
4f0312f3
编写于
12月 20, 2013
作者:
D
David Calavera
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Move `isEmptyDir` to the command utilities.
Removes duplicated test helper.
上级
6b14600f
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
39 addition
and
40 deletion
+39
-40
commands/release.go
commands/release.go
+1
-1
commands/release_test.go
commands/release_test.go
+0
-8
commands/utils.go
commands/utils.go
+7
-0
commands/utils_test.go
commands/utils_test.go
+31
-0
utils/utils.go
utils/utils.go
+0
-6
utils/utils_test.go
utils/utils_test.go
+0
-25
未找到文件。
commands/release.go
浏览文件 @
4f0312f3
...
...
@@ -140,7 +140,7 @@ func getAssetsDirectory(assetsDir, tag string) (string, error) {
return
""
,
fmt
.
Errorf
(
"The assets directory doesn't exist: %s"
,
assetsDir
)
}
if
utils
.
I
sEmptyDir
(
assetsDir
)
{
if
i
sEmptyDir
(
assetsDir
)
{
return
""
,
fmt
.
Errorf
(
"The assets directory is empty: %s"
,
assetsDir
)
}
...
...
commands/release_test.go
浏览文件 @
4f0312f3
...
...
@@ -50,11 +50,3 @@ func assertAssetsDirSelected(t *testing.T, expectedDir, flagDir string) {
assert
.
Equal
(
t
,
nil
,
err
)
assert
.
T
(
t
,
os
.
SameFile
(
fiExpected
,
fiAssets
))
}
func
createTempDir
(
t
*
testing
.
T
)
string
{
dir
,
err
:=
ioutil
.
TempDir
(
""
,
"gh-test-"
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
return
dir
}
commands/utils.go
浏览文件 @
4f0312f3
...
...
@@ -5,6 +5,7 @@ import (
"github.com/jingweno/gh/utils"
"github.com/jingweno/go-octokit/octokit"
"os"
"path/filepath"
"strings"
)
...
...
@@ -46,3 +47,9 @@ func hasGitRemote(name string) bool {
return
false
}
func
isEmptyDir
(
path
string
)
bool
{
fullPath
:=
filepath
.
Join
(
path
,
"*"
)
match
,
_
:=
filepath
.
Glob
(
fullPath
)
return
match
==
nil
}
commands/utils_test.go
0 → 100644
浏览文件 @
4f0312f3
package
commands
import
(
"github.com/bmizerany/assert"
"io/ioutil"
"os"
"testing"
)
func
TestDirIsNotEmpty
(
t
*
testing
.
T
)
{
dir
:=
createTempDir
(
t
)
defer
os
.
RemoveAll
(
dir
)
ioutil
.
TempFile
(
dir
,
"gh-utils-test-"
)
assert
.
Equal
(
t
,
false
,
isEmptyDir
(
dir
))
}
func
TestDirIsEmpty
(
t
*
testing
.
T
)
{
dir
:=
createTempDir
(
t
)
defer
os
.
RemoveAll
(
dir
)
assert
.
T
(
t
,
isEmptyDir
(
dir
))
}
func
createTempDir
(
t
*
testing
.
T
)
string
{
dir
,
err
:=
ioutil
.
TempDir
(
""
,
"gh-utils-test-"
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
return
dir
}
utils/utils.go
浏览文件 @
4f0312f3
...
...
@@ -64,9 +64,3 @@ func DirName() (string, error) {
name
=
strings
.
Replace
(
name
,
" "
,
"-"
,
-
1
)
return
name
,
nil
}
func
IsEmptyDir
(
path
string
)
bool
{
fullPath
:=
filepath
.
Join
(
path
,
"*"
)
match
,
_
:=
filepath
.
Glob
(
fullPath
)
return
match
==
nil
}
utils/utils_test.go
浏览文件 @
4f0312f3
...
...
@@ -2,8 +2,6 @@ package utils
import
(
"github.com/bmizerany/assert"
"io/ioutil"
"os"
"testing"
)
...
...
@@ -18,26 +16,3 @@ func TestSearchBrowserLauncher(t *testing.T) {
func
TestConcatPaths
(
t
*
testing
.
T
)
{
assert
.
Equal
(
t
,
"foo/bar/baz"
,
ConcatPaths
(
"foo"
,
"bar"
,
"baz"
))
}
func
TestDirIsNotEmpty
(
t
*
testing
.
T
)
{
dir
:=
createTempDir
(
t
)
defer
os
.
RemoveAll
(
dir
)
ioutil
.
TempFile
(
dir
,
"gh-utils-test-"
)
assert
.
Equal
(
t
,
false
,
IsEmptyDir
(
dir
))
}
func
TestDirIsEmpty
(
t
*
testing
.
T
)
{
dir
:=
createTempDir
(
t
)
defer
os
.
RemoveAll
(
dir
)
assert
.
T
(
t
,
IsEmptyDir
(
dir
))
}
func
createTempDir
(
t
*
testing
.
T
)
string
{
dir
,
err
:=
ioutil
.
TempDir
(
""
,
"gh-utils-test-"
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
return
dir
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录