Skip to content

Commit

Permalink
feat: Enable module git_commit by default with option `only_detache…
Browse files Browse the repository at this point in the history
…d' set (+ adapt docs accordingly)
  • Loading branch information
ybc37 committed Feb 7, 2020
1 parent 726e638 commit 5edfe88
Show file tree
Hide file tree
Showing 11 changed files with 44 additions and 107 deletions.
12 changes: 2 additions & 10 deletions docs/config/README.md
Expand Up @@ -493,13 +493,6 @@ truncation_symbol = ""

The `git_commit` module shows the current commit hash of the repo in your current directory.

::: tip

This module is disabled by default.
To enable it, set `disabled` to `false` in your configuration file.

:::

### Options

| Variable | Default | Description |
Expand All @@ -508,16 +501,15 @@ To enable it, set `disabled` to `false` in your configuration file.
| `prefix` | `"("` | Prefix to display immediately before git commit. |
| `suffix` | `")"` | Suffix to display immediately after git commit. |
| `style` | `"bold green"` | The style for the module. |
| `only_detached` | `false` | Only show git commit hash when in detached HEAD state |
| `disabled` | `true` | Disables the `git_commit` module. |
| `only_detached` | `true` | Only show git commit hash when in detached HEAD state |
| `disabled` | `false` | Disables the `git_commit` module. |

### Example

```toml
# ~/.config/starship.toml

[git_commit]
disabled = false
commit_hash_length = 4
```

Expand Down
22 changes: 8 additions & 14 deletions docs/de-DE/config/README.md
Expand Up @@ -463,29 +463,23 @@ truncation_symbol = ""

The `git_commit` module shows the current commit hash of the repo in your current directory.

::: tip

Dieses Modul ist standardmäßig deaktiviert. Setze in deiner Konfiguration `disabled` auf `false` um es zu aktivieren.

:::

### Optionen

| Variable | Standardwert | Beschreibung |
| -------------------- | -------------- | ------------------------------------------------ |
| `commit_hash_length` | `7` | The length of the displayed git commit hash. |
| `prefix` | `"("` | Prefix to display immediately before git commit. |
| `suffix` | `")"` | Suffix to display immediately after git commit. |
| `style` | `"bold green"` | Stil für dieses Modul. |
| `disabled` | `true` | Disables the `git_commit` module. |
| Variable | Standardwert | Beschreibung |
| -------------------- | -------------- | ------------------------------------------------------- |
| `commit_hash_length` | `7` | The length of the displayed git commit hash. |
| `prefix` | `"("` | Prefix to display immediately before git commit. |
| `suffix` | `")"` | Suffix to display immediately after git commit. |
| `style` | `"bold green"` | Stil für dieses Modul. |
| `only_detached` | `true` | Zeigt den Commit Hash nur im Status "detached HEAD" an. |
| `disabled` | `false` | Disables the `git_commit` module. |

### Beispiel

```toml
# ~/.config/starship.toml

[git_commit]
disabled = false
commit_hash_length = 4
```

Expand Down
22 changes: 8 additions & 14 deletions docs/es-ES/config/README.md
Expand Up @@ -463,29 +463,23 @@ truncation_symbol = ""

The `git_commit` module shows the current commit hash of the repo in your current directory.

::: tip

This module is disabled by default. To enable it, set `disabled` to `false` in your configuration file.

:::

### Options

| Variable | Default | Description |
| -------------------- | -------------- | ------------------------------------------------ |
| `commit_hash_length` | `7` | The length of the displayed git commit hash. |
| `prefix` | `"("` | Prefix to display immediately before git commit. |
| `suffix` | `")"` | Suffix to display immediately after git commit. |
| `style` | `"bold green"` | The style for the module. |
| `disabled` | `true` | Disables the `git_commit` module. |
| Variable | Default | Description |
| -------------------- | -------------- | ----------------------------------------------------- |
| `commit_hash_length` | `7` | The length of the displayed git commit hash. |
| `prefix` | `"("` | Prefix to display immediately before git commit. |
| `suffix` | `")"` | Suffix to display immediately after git commit. |
| `style` | `"bold green"` | The style for the module. |
| `only_detached` | `true` | Only show git commit hash when in detached HEAD state |
| `disabled` | `false` | Disables the `git_commit` module. |

### Example

```toml
# ~/.config/starship.toml

[git_commit]
disabled = false
commit_hash_length = 4
```

Expand Down
22 changes: 8 additions & 14 deletions docs/fr-FR/config/README.md
Expand Up @@ -463,29 +463,23 @@ truncation_symbol = ""

The `git_commit` module shows the current commit hash of the repo in your current directory.

::: tip

This module is disabled by default. To enable it, set `disabled` to `false` in your configuration file.

:::

### Options

| Variable | Default | Description |
| -------------------- | -------------- | ------------------------------------------------ |
| `commit_hash_length` | `7` | The length of the displayed git commit hash. |
| `prefix` | `"("` | Prefix to display immediately before git commit. |
| `suffix` | `")"` | Suffix to display immediately after git commit. |
| `style` | `"bold green"` | The style for the module. |
| `disabled` | `true` | Disables the `git_commit` module. |
| Variable | Default | Description |
| -------------------- | -------------- | ----------------------------------------------------- |
| `commit_hash_length` | `7` | The length of the displayed git commit hash. |
| `prefix` | `"("` | Prefix to display immediately before git commit. |
| `suffix` | `")"` | Suffix to display immediately after git commit. |
| `style` | `"bold green"` | The style for the module. |
| `only_detached` | `true` | Only show git commit hash when in detached HEAD state |
| `disabled` | `false` | Disables the `git_commit` module. |

### Example

```toml
# ~/.config/starship.toml

[git_commit]
disabled = false
commit_hash_length = 4
```

Expand Down
10 changes: 2 additions & 8 deletions docs/ja-JP/config/README.md
Expand Up @@ -463,12 +463,6 @@ truncation_symbol = ""

`git_commit`モジュールは、現在のディレクトリにあるリポジトリの現在のコミットハッシュを表示します。

::: tip

このモジュールはデフォルトで無効になっています。 有効にするには、設定ファイルで`disabled``false`に設定します。

:::

### オプション

| 変数 | デフォルト | 説明 |
Expand All @@ -477,15 +471,15 @@ truncation_symbol = ""
| `prefix` | `"("` | このモジュールの先頭に表示される文字列です。 |
| `suffix` | `")"` | このモジュールの末尾に表示される文字列です。 |
| `style` | `"bold green"` | モジュールのスタイルです。 |
| `disabled` | `true` | `git_commit`モジュールを無効にします。 |
| `only_detached` | `true` | Only show git commit hash when in detached HEAD state |
| `disabled` | `false` | `git_commit`モジュールを無効にします。 |

### 設定例

```toml
# ~/.config/starship.toml

[git_commit]
disabled = false
commit_hash_length = 4
```

Expand Down
22 changes: 8 additions & 14 deletions docs/ru-RU/config/README.md
Expand Up @@ -463,29 +463,23 @@ truncation_symbol = ""

Модуль `git_commit` показывает хэш текущего коммита репозитория в вашем текущем каталоге.

::: tip Подсказка

По умолчанию этот модуль отключен. Чтобы включить его, установите `disabled` на `false` в файле конфигурации.

:::

### Опции

| Переменная | По умолчанию | Описание |
| -------------------- | -------------- | ---------------------------------------------- |
| `commit_hash_length` | `7` | Длина отображаемого хэша коммита git. |
| `prefix` | `"("` | Префикс, отображаемый сразу после коммита. |
| `suffix` | `")"` | Суффикс, отображаемый сразу после коммита git. |
| `style` | `"bold green"` | Стиль модуля. |
| `disabled` | `true` | Отключает модуль `git_commit`. |
| Переменная | По умолчанию | Описание |
| -------------------- | -------------- | ----------------------------------------------------- |
| `commit_hash_length` | `7` | Длина отображаемого хэша коммита git. |
| `prefix` | `"("` | Префикс, отображаемый сразу после коммита. |
| `suffix` | `")"` | Суффикс, отображаемый сразу после коммита git. |
| `style` | `"bold green"` | Стиль модуля. |
| `only_detached` | `true` | Only show git commit hash when in detached HEAD state |
| `disabled` | `false` | Отключает модуль `git_commit`. |

### Пример

```toml
# ~/.config/starship.toml

[git_commit]
disabled = false
commit_hash_length = 4
```

Expand Down
10 changes: 2 additions & 8 deletions docs/zh-CN/config/README.md
Expand Up @@ -463,12 +463,6 @@ truncation_symbol = ""

`git_commit` 组件显示当前目录的 git 仓库的当前提交的哈希值。

::: tip

此组件默认被禁用。 若要启用此组件,请在配置文件中设置 `disable` 字段为 `false`

:::

### 配置项

| 字段 | 默认值 | 描述 |
Expand All @@ -477,15 +471,15 @@ truncation_symbol = ""
| `prefix` | `"("` | 直接在 git 提交哈希值前显示的前缀。 |
| `suffix` | `")"` | 直接在 git 提交哈希值后显示的后缀。 |
| `style` | `"bold green"` | 此组件的样式。 |
| `disabled` | `true` | 禁用 `git_commit` 组件。 |
| `only_detached` | `true` | Only show git commit hash when in detached HEAD state |
| `disabled` | `false` | 禁用 `git_commit` 组件。 |

### 示例

```toml
# ~/.config/starship.toml

[git_commit]
disabled = false
commit_hash_length = 4
```

Expand Down
10 changes: 2 additions & 8 deletions docs/zh-TW/config/README.md
Expand Up @@ -463,12 +463,6 @@ truncation_symbol = ""

The `git_commit` module shows the current commit hash of the repo in your current directory.

::: tip

這個模組預設是停用的。 想要啟用它的話,請在設定檔中將 `disabled` 設定為 `false`

:::

### 選項

| 變數 | 預設 | 說明 |
Expand All @@ -477,15 +471,15 @@ The `git_commit` module shows the current commit hash of the repo in your curren
| `prefix` | `"("` | Prefix to display immediately before git commit. |
| `suffix` | `")"` | Suffix to display immediately after git commit. |
| `style` | `"bold green"` | 這個模組的風格。 |
| `disabled` | `true` | Disables the `git_commit` module. |
| `only_detached` | `true` | Only show git commit hash when in detached HEAD state |
| `disabled` | `false` | Disables the `git_commit` module. |

### 範例

```toml
# ~/.config/starship.toml

[git_commit]
disabled = false
commit_hash_length = 4
```

Expand Down
4 changes: 2 additions & 2 deletions src/configs/git_commit.rs
Expand Up @@ -23,8 +23,8 @@ impl<'a> RootModuleConfig<'a> for GitCommitConfig<'a> {
prefix: "(",
suffix: ") ",
style: Color::Green.bold(),
only_detached: false,
disabled: true,
only_detached: true,
disabled: false,
}
}
}
3 changes: 0 additions & 3 deletions src/modules/git_commit.rs
Expand Up @@ -9,9 +9,6 @@ use crate::configs::git_commit::GitCommitConfig;
pub fn module<'a>(context: &'a Context) -> Option<Module<'a>> {
let mut module = context.new_module("git_commit");
let config = GitCommitConfig::try_load(module.config);
if config.disabled {
return None;
};

module
.get_prefix()
Expand Down
14 changes: 2 additions & 12 deletions tests/testsuite/git_commit.rs
Expand Up @@ -19,7 +19,7 @@ fn test_render_commit_hash() -> io::Result<()> {
let output = common::render_module("git_commit")
.use_config(toml::toml! {
[git_commit]
disabled = false
only_detached = false
})
.arg("--path")
.arg(repo_dir)
Expand Down Expand Up @@ -50,7 +50,7 @@ fn test_render_commit_hash_len_override() -> io::Result<()> {
let output = common::render_module("git_commit")
.use_config(toml::toml! {
[git_commit]
disabled = false
only_detached = false
commit_hash_length = 14
})
.arg("--path")
Expand All @@ -72,11 +72,6 @@ fn test_render_commit_hash_only_detached_on_branch() -> io::Result<()> {
let repo_dir = common::create_fixture_repo()?;

let output = common::render_module("git_commit")
.use_config(toml::toml! {
[git_commit]
disabled = false
only_detached = true
})
.arg("--path")
.arg(repo_dir)
.output()?;
Expand Down Expand Up @@ -105,11 +100,6 @@ fn test_render_commit_hash_only_detached_on_detached() -> io::Result<()> {
let expected_hash = str::from_utf8(&git_output).unwrap();

let output = common::render_module("git_commit")
.use_config(toml::toml! {
[git_commit]
disabled = false
only_detached = true
})
.arg("--path")
.arg(repo_dir)
.output()?;
Expand Down

0 comments on commit 5edfe88

Please sign in to comment.