Skip to content

Commit

Permalink
feat: search repository
Browse files Browse the repository at this point in the history
  • Loading branch information
icyleaf committed Apr 28, 2018
1 parent 79f408a commit 7af94e3
Show file tree
Hide file tree
Showing 12 changed files with 273 additions and 33 deletions.
2 changes: 1 addition & 1 deletion docs/_coverpage.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
![logo](_media/icon.png)

# ḫpr <small>0.5.0</small>
# ḫpr <small>0.6.0</small>

> 镜像任意 git 仓库到 gitlab 的同步工具,具有定时更新的功能。
Expand Down
46 changes: 45 additions & 1 deletion docs/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,50 @@ GET /repositores
}
```

### 搜索镜像仓库

根据关键词搜索镜像仓库,只要关键词匹配到任意镜像仓库名的字符串均会命中。

```
GET /repositores/search/?q=[query]
```

#### 参数

| 名称 | 类型 | 是否必须 | 描述 |
|---|---|---|---|
| q | String | true | 搜索关键词 |

#### 返回样例

```json
{
"total": 2,
"data": [
{
"name": "coding-coding-docs",
"url": "https://git.coding.net/coding/coding-docs.git",
"mirror_url": "[email protected]:hpr-mirrors/coding-coding-docs.git",
"latest_version": "",
"status": "idle",
"created_at": "2018-03-23 16:27:59 +0800",
"updated_at": "2018-03-23 16:27:59 +0800",
"scheduled_at": "2018-03-23 17:28:02 +0800"
},
{
"name": "spf13-viper",
"url": "https://github.com/spf13/viper.git",
"mirror_url": "[email protected]:hpr-mirrors/spf13-viper.git",
"latest_version": "v1.0.2",
"status": "idle",
"created_at": "2018-03-23 16:36:00 +0800",
"updated_at": "2018-03-23 16:36:00 +0800",
"scheduled_at": "2018-03-23 17:36:02 +0800"
}
]
}
```

### 单个镜像仓库信息

```
Expand Down Expand Up @@ -180,7 +224,7 @@ GET /info
```json
{
"hpr": {
"version": "0.5.0",
"version": "0.6.0",
"repositroies": {
"total": 2,
"entry": [
Expand Down
61 changes: 55 additions & 6 deletions docs/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ hpr 本身是一个命令行工具,因此也提供了一个临时可用的辅
## 运行 Web API 服务器

```bash
$ hpr -s
$ hpr -s
# 或者更改端口号
$ hpr -s --port 8848
_
Expand All @@ -23,17 +23,62 @@ $ hpr -s --port 8848
$ hpr -l
# or
$ hpr --list
2018-04-26 17:05:44 +08:00 INFO listing repositories (2):
* icyleaf-halite
* icyleaf-gitlab.cr
2018-04-28 18:01:32 +08:00 INFO listing repositories (2):
=> Name: icyleaf-gitlab.cr
Path: /Users/icyleaf/data/repositories/icyleaf-gitlab.cr
OriginalUrl: https://github.com/icyleaf/gitlab.cr
MirrorUrl: [email protected]:hpr-mirrors/icyleaf-gitlab.cr.git
Status: idle
CreatedAt: 2018-04-26 17:05:44 +0800
UpdatedAt: 2018-04-26 17:05:46 +0800
ScheduledAt: 2018-04-29 05:05:46 +0800
=> Name: icyleaf-salt
Path: /Users/icyleaf/data/repositories/icyleaf-salt
OriginalUrl: https://github.com/icyleaf/salt.git
MirrorUrl: [email protected]:hpr-mirrors/icyleaf-salt.git
Status: idle
CreatedAt: 2018-04-28 18:00:56 +0800
UpdatedAt: 2018-04-28 18:00:58 +0800
ScheduledAt: 2018-05-01 06:00:58 +0800
```
## 搜索镜像仓库
```bash
$ hpr -S icyleaf
# or
$ hpr --search icyleaf
2018-04-28 18:07:34 +08:00 INFO searching repositories ... icyleaf
2018-04-28 18:07:34 +08:00 INFO found repositories (2):
=> Name: icyleaf-gitlab.cr
Path: /Users/icyleaf/data/repositories/icyleaf-gitlab.cr
OriginalUrl: https://github.com/icyleaf/gitlab.cr
MirrorUrl: [email protected]:hpr-mirrors/icyleaf-gitlab.cr.git
Status: idle
CreatedAt: 2018-04-26 17:05:44 +0800
UpdatedAt: 2018-04-26 17:05:46 +0800
ScheduledAt: 2018-04-29 05:05:46 +0800
=> Name: icyleaf-salt
Path: /Users/icyleaf/data/repositories/icyleaf-salt
OriginalUrl: https://github.com/icyleaf/salt.git
MirrorUrl: [email protected]:hpr-mirrors/icyleaf-salt.git
Status: idle
CreatedAt: 2018-04-28 18:00:56 +0800
UpdatedAt: 2018-04-28 18:00:58 +0800
ScheduledAt: 2018-05-01 06:00:58 +0800
```
## 创建镜像仓库
```bash
$ hpr --create --url https://github.com/icyleaf/salt.git icyleaf-salt
$ hpr -c -U https://github.com/icyleaf/salt.git icyleaf-salt
# or
$ hpr -c -U https://github.com/icyleaf/salt.git
$ hpr --create --url https://github.com/icyleaf/salt.git
2018-04-26 17:04:39 +08:00 INFO creating repository ... ews-team/icyleaf-salt
2018-04-26 17:04:41 +08:00 INFO cloning https://github.com/icyleaf/salt.cr ... icyleaf-salt
2018-04-26 17:05:44 +08:00 INFO pushing to mirror ... icyleaf-salt
Expand All @@ -44,6 +89,8 @@ $ hpr -c -U https://github.com/icyleaf/salt.git
```bash
$ hpr -u icyleaf-salt
# or
$ hpr --update icyleaf-salt
2018-04-26 17:04:01 +08:00 INFO updating from origin ... icyleaf-salt
2018-04-26 17:04:06 +08:00 INFO pushing to mirror ... icyleaf-salt
2018-04-26 17:04:07 +08:00 INFO update repository ... done
Expand All @@ -53,6 +100,8 @@ $ hpr -u icyleaf-salt
```bash
$ hpr -d icyleaf-salt
# or
$ hpr --delete icyleaf-salt
2018-04-26 17:04:25 +08:00 INFO destroying project ... ews-team/icyleaf-salt
2018-04-26 17:04:25 +08:00 INFO deleting directory ... icyleaf-salt
2018-04-26 17:04:26 +08:00 INFO delete repository ... done
Expand Down
2 changes: 1 addition & 1 deletion docs/en/_coverpage.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
![logo](../_media/icon.png)

# ḫpr <small>0.5.0</small>
# ḫpr <small>0.6.0</small>

> Mirror git repositories to self-host gitlab services.
Expand Down
43 changes: 43 additions & 0 deletions docs/en/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,49 @@ GET /repositores
}
```

### Search repositories

Search repositories by given query keywords, returns all include keyword matchs the name of mirrored reposotories.

```
GET /repositores/search/?q=[query]
```

#### Parameters

| Name | Type | Required | Description |
|---|---|---|---|
| q | String | true | keyworkd |

#### Example Response

```json
{
"total": 2,
"data": [
{
"name": "coding-coding-docs",
"url": "https://git.coding.net/coding/coding-docs.git",
"mirror_url": "[email protected]:hpr-mirrors/coding-coding-docs.git",
"latest_version": "",
"status": "idle",
"created_at": "2018-03-23 16:27:59 +0800",
"updated_at": "2018-03-23 16:27:59 +0800",
"scheduled_at": "2018-03-23 17:28:02 +0800"
},
{
"name": "spf13-viper",
"url": "https://github.com/spf13/viper.git",
"mirror_url": "[email protected]:hpr-mirrors/spf13-viper.git",
"latest_version": "v1.0.2",
"status": "idle",
"created_at": "2018-03-23 16:36:00 +0800",
"updated_at": "2018-03-23 16:36:00 +0800",
"scheduled_at": "2018-03-23 17:36:02 +0800"
}
]
}
```

### Get a repository info

Expand Down
61 changes: 55 additions & 6 deletions docs/en/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ hpr is a command line tool, it also support some commands to manage mirror repos
## Run Web API server

```bash
$ hpr -s
$ hpr -s
# Or customize server port
$ hpr -s --port 8848
_
Expand All @@ -23,17 +23,62 @@ $ hpr -s --port 8848
$ hpr -l
# or
$ hpr --list
2018-04-26 17:05:44 +08:00 INFO listing repositories (2):
* icyleaf-halite
* icyleaf-gitlab.cr
2018-04-28 18:01:32 +08:00 INFO listing repositories (2):
=> Name: icyleaf-gitlab.cr
Path: /Users/icyleaf/data/repositories/icyleaf-gitlab.cr
OriginalUrl: https://github.com/icyleaf/gitlab.cr
MirrorUrl: [email protected]:hpr-mirrors/icyleaf-gitlab.cr.git
Status: idle
CreatedAt: 2018-04-26 17:05:44 +0800
UpdatedAt: 2018-04-26 17:05:46 +0800
ScheduledAt: 2018-04-29 05:05:46 +0800
=> Name: icyleaf-salt
Path: /Users/icyleaf/data/repositories/icyleaf-salt
OriginalUrl: https://github.com/icyleaf/salt.git
MirrorUrl: [email protected]:hpr-mirrors/icyleaf-salt.git
Status: idle
CreatedAt: 2018-04-28 18:00:56 +0800
UpdatedAt: 2018-04-28 18:00:58 +0800
ScheduledAt: 2018-05-01 06:00:58 +0800
```
## Search repositories
```bash
$ hpr -S icyleaf
# or
$ hpr --search icyleaf
2018-04-28 18:07:34 +08:00 INFO searching repositories ... icyleaf
2018-04-28 18:07:34 +08:00 INFO found repositories (2):
=> Name: icyleaf-gitlab.cr
Path: /Users/icyleaf/data/repositories/icyleaf-gitlab.cr
OriginalUrl: https://github.com/icyleaf/gitlab.cr
MirrorUrl: [email protected]:hpr-mirrors/icyleaf-gitlab.cr.git
Status: idle
CreatedAt: 2018-04-26 17:05:44 +0800
UpdatedAt: 2018-04-26 17:05:46 +0800
ScheduledAt: 2018-04-29 05:05:46 +0800
=> Name: icyleaf-salt
Path: /Users/icyleaf/data/repositories/icyleaf-salt
OriginalUrl: https://github.com/icyleaf/salt.git
MirrorUrl: [email protected]:hpr-mirrors/icyleaf-salt.git
Status: idle
CreatedAt: 2018-04-28 18:00:56 +0800
UpdatedAt: 2018-04-28 18:00:58 +0800
ScheduledAt: 2018-05-01 06:00:58 +0800
```
## Create a new repository
```bash
$ hpr --create --url https://github.com/icyleaf/salt.git icyleaf-salt
$ hpr -c -U https://github.com/icyleaf/salt.git icyleaf-salt
# or
$ hpr -c -U https://github.com/icyleaf/salt.git
$ hpr --create --url https://github.com/icyleaf/salt.git
2018-04-26 17:04:39 +08:00 INFO creating repository ... ews-team/icyleaf-salt
2018-04-26 17:04:41 +08:00 INFO cloning https://github.com/icyleaf/salt.cr ... icyleaf-salt
2018-04-26 17:05:44 +08:00 INFO pushing to mirror ... icyleaf-salt
Expand All @@ -44,6 +89,8 @@ $ hpr -c -U https://github.com/icyleaf/salt.git
```bash
$ hpr -u icyleaf-salt
# or
$ hpr --update icyleaf-salt
2018-04-26 17:04:01 +08:00 INFO updating from origin ... icyleaf-salt
2018-04-26 17:04:06 +08:00 INFO pushing to mirror ... icyleaf-salt
2018-04-26 17:04:07 +08:00 INFO update repository ... done
Expand All @@ -53,6 +100,8 @@ $ hpr -u icyleaf-salt
```bash
$ hpr -d icyleaf-salt
# or
$ hpr --delete icyleaf-salt
2018-04-26 17:04:25 +08:00 INFO destroying project ... ews-team/icyleaf-salt
2018-04-26 17:04:25 +08:00 INFO deleting directory ... icyleaf-salt
2018-04-26 17:04:26 +08:00 INFO delete repository ... done
Expand Down
9 changes: 7 additions & 2 deletions docs/en/install.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Check [Quick start](/en/quickstart.md)。
Pull specified version of hpr:

```bash
$ docker pull icyleafcn/hpr:0.5.0
$ docker pull icyleafcn/hpr:0.6.0
```

Or pull the latest version:
Expand Down Expand Up @@ -95,6 +95,7 @@ Actions:

-s, --server Run a web api server
-l, --list List mirrored repositories
-S, --search Search mirrored repositories
-c, --create Create a mirror repository
-u, --update Updated a mirrored repository
-d, --delete Delete a mirrored repository
Expand Down Expand Up @@ -127,6 +128,10 @@ Examples:

$ hpr -s --port 3001

o Search all repositories include icyleaf keywords:

$ hpr -S icyleaf

o Create a new repository:

$ hpr -c --url https://github.com/icyleaf/hpr.git icyleaf-hpr
Expand All @@ -145,5 +150,5 @@ Examples:

More detail to check: https://icyleaf.github.io/hpr/

hpr v0.5.0 in Crystal v0.24.2
hpr v0.6.0 in Crystal v0.24.2
```
9 changes: 7 additions & 2 deletions docs/install.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ hpr 使用 Crystal 编写的工具可以被安装在 macOS、Linux、树莓派
获取指定版本的 hpr:

```bash
$ docker pull icyleafcn/hpr:0.5.0
$ docker pull icyleafcn/hpr:0.6.0
```

或者获取最新版本的 hpr:
Expand Down Expand Up @@ -95,6 +95,7 @@ Actions:

-s, --server Run a web api server
-l, --list List mirrored repositories
-S, --search Search mirrored repositories
-c, --create Create a mirror repository
-u, --update Updated a mirrored repository
-d, --delete Delete a mirrored repository
Expand Down Expand Up @@ -127,6 +128,10 @@ Examples:

$ hpr -s --port 3001

o Search all repositories include icyleaf keywords:

$ hpr -S icyleaf

o Create a new repository:

$ hpr -c --url https://github.com/icyleaf/hpr.git icyleaf-hpr
Expand All @@ -145,5 +150,5 @@ Examples:

More detail to check: https://icyleaf.github.io/hpr/

hpr v0.5.0 in Crystal v0.24.2
hpr v0.6.0 in Crystal v0.24.2
```
Loading

0 comments on commit 7af94e3

Please sign in to comment.