Skip to content

Commit b2a7b96

Browse files
committed
Add config value for skipping recent repositories prompt
The configuration key `notARepository` configures the action to be taken when opening Lazygit outside of a git repo. Possible values - 'prompt': (default) ask whether to initialize a new repo or open in the most recent repo - 'create': initialize a new repo - 'skip': open most recent repo - 'quit': exit Lazygit With `notARepository: skip`, the most recent repository is selected, but a "Recent repositories" prompt is still opened. Proposed change: - `notARepository: recent` opens the "Recent repositories" prompt - `notARepository: skip` skips the modal
1 parent 0a1ddba commit b2a7b96

File tree

11 files changed

+21
-11
lines changed

11 files changed

+21
-11
lines changed

docs/Config.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -473,7 +473,8 @@ services: {}
473473
# What to do when opening Lazygit outside of a git repo.
474474
# - 'prompt': (default) ask whether to initialize a new repo or open in the most recent repo
475475
# - 'create': initialize a new repo
476-
# - 'skip': open most recent repo
476+
# - 'recent': open most recent repo
477+
# - 'skip': open most recent repo and skip the modal
477478
# - 'quit': exit Lazygit
478479
notARepository: prompt
479480

@@ -1081,6 +1082,11 @@ notARepository: 'prompt'
10811082
notARepository: 'create'
10821083
```
10831084

1085+
```yaml
1086+
# to select from recent repositories
1087+
notARepository: 'recent'
1088+
```
1089+
10841090
```yaml
10851091
# to skip without creating a new repo
10861092
notARepository: 'skip'

pkg/app/app.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,8 @@ func (app *App) setupRepo(
209209
}
210210
case "create":
211211
shouldInitRepo = true
212+
case "recent":
213+
shouldInitRepo = false
212214
case "skip":
213215
shouldInitRepo = false
214216
case "quit":

pkg/config/user_config.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,10 @@ type UserConfig struct {
3131
// What to do when opening Lazygit outside of a git repo.
3232
// - 'prompt': (default) ask whether to initialize a new repo or open in the most recent repo
3333
// - 'create': initialize a new repo
34-
// - 'skip': open most recent repo
34+
// - 'recent': open most recent repo
35+
// - 'skip': open most recent repo and skip the modal
3536
// - 'quit': exit Lazygit
36-
NotARepository string `yaml:"notARepository" jsonschema:"enum=prompt,enum=create,enum=skip,enum=quit"`
37+
NotARepository string `yaml:"notARepository" jsonschema:"enum=prompt,enum=create,enum=recent,enum=skip,enum=quit"`
3738
// If true, display a confirmation when subprocess terminates. This allows you to view the output of the subprocess before returning to Lazygit.
3839
PromptToReturnFromSubprocess bool `yaml:"promptToReturnFromSubprocess"`
3940
// Keybindings

pkg/gui/layout.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ func (gui *Gui) onInitialViewsCreation() error {
260260
gui.c.GetAppState().LastVersion = gui.Config.GetVersion()
261261
gui.c.SaveAppStateAndLogError()
262262

263-
if gui.showRecentRepos {
263+
if gui.showRecentRepos && gui.c.UserConfig().NotARepository != "skip" {
264264
if err := gui.helpers.Repos.CreateRecentReposMenu(); err != nil {
265265
return err
266266
}

pkg/i18n/english.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1475,7 +1475,7 @@ func EnglishTranslationSet() *TranslationSet {
14751475
BareRepo: "You've attempted to open Lazygit in a bare repo but Lazygit does not yet support bare repos. Open most recent repo? (y/n) ",
14761476
InitialBranch: "Branch name? (leave empty for git's default): ",
14771477
NoRecentRepositories: "Must open lazygit in a git repository. No valid recent repositories. Exiting.",
1478-
IncorrectNotARepository: "The value of 'notARepository' is incorrect. It should be one of 'prompt', 'create', 'skip', or 'quit'.",
1478+
IncorrectNotARepository: "The value of 'notARepository' is incorrect. It should be one of 'prompt', 'create', 'recent', 'skip', or 'quit'.",
14791479
AutoStashTitle: "Autostash?",
14801480
AutoStashPrompt: "You must stash and pop your changes to bring them across. Do this automatically? (enter/esc)",
14811481
AutoStashForUndo: "Auto-stashing changes for undoing to %s",

pkg/i18n/translations/pl.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@
323323
"BareRepo": "Próbujesz otworzyć Lazygit w gołym repozytorium, ale Lazygit jeszcze nie obsługuje gołych repozytoriów. Otworzyć najnowsze repozytorium? (t/n) ",
324324
"InitialBranch": "Nazwa gałęzi? (pozostaw puste dla domyślnej gita): ",
325325
"NoRecentRepositories": "Musisz otworzyć lazygit w repozytorium git. Brak ważnych ostatnich repozytoriów. Wyjście.",
326-
"IncorrectNotARepository": "Wartość 'notARepository' jest nieprawidłowa. Powinna być jedną z 'prompt', 'create', 'skip', lub 'quit'.",
326+
"IncorrectNotARepository": "Wartość 'notARepository' jest nieprawidłowa. Powinna być jedną z 'prompt', 'create', 'recent', 'skip', lub 'quit'.",
327327
"AutoStashPrompt": "Musisz schować i wyciągnąć swoje zmiany, aby je przenieść. Zrobić to automatycznie? (enter/esc)",
328328
"Discard": "Odrzuć",
329329
"DiscardChangesTitle": "Odrzuć zmiany",

pkg/i18n/translations/pt.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,7 @@
391391
"BareRepo": "Você tentou abrir Lazygit em um repositório puro, mas Lazygit ainda não suporta repositórios vazios. Abrir os repositórios mais recentes? (y/n) ",
392392
"InitialBranch": "Nome da branch? (deixe vazio para o padrão do git): ",
393393
"NoRecentRepositories": "É necessário abrir lazygit em um repositório git. Nenhum repositório recente válido. Saindo do sistema.",
394-
"IncorrectNotARepository": "O valor de 'notARepository' está incorreto. Deve ser um dos 'prompt', 'create', 'sk', ou 'quit'.",
394+
"IncorrectNotARepository": "O valor de 'notARepository' está incorreto. Deve ser um dos 'prompt', 'create', 'recent', 'skip', ou 'quit'.",
395395
"AutoStashTitle": "Autoarmazenar?",
396396
"AutoStashPrompt": "Você deve esconder e mostrar suas alterações para que elas passem. Quer fazer isso automaticamente? (enter/esc)",
397397
"Discard": "Descartar",

pkg/i18n/translations/ru.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@
244244
"BareRepo": "Вы пытались открыть Lazygit в пустом репозитории, но Lazygit ещё не поддерживает пустые репозитории. Открыть последний репозиторий? (y/n)",
245245
"InitialBranch": "Название ветки? (оставьте пустым для git по умолчанию):",
246246
"NoRecentRepositories": "Необходимо открыть lazygit в git репозитории. Нет валидных последних репозиториев. Выход.",
247-
"IncorrectNotARepository": "Неверное значение 'notARepository'. Это должно быть одним из 'prompt', 'create', 'skip', или 'quit'.",
247+
"IncorrectNotARepository": "Неверное значение 'notARepository'. Это должно быть одним из 'prompt', 'create', 'recent', 'skip', или 'quit'.",
248248
"AutoStashTitle": "Автосохранить изменения?",
249249
"AutoStashPrompt": "Чтобы перенести изменения, их нужно сохранить и вынуть. Сделать это автоматически? (enter/esc)",
250250
"Discard": "Просмотреть параметры «отмены изменении»",

pkg/i18n/translations/zh-CN.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,7 @@
403403
"BareRepo": "您已经尝试在空仓库中打开Lazygit,但是Lazygit还不支持空仓库。打开最近的仓库吗?(y / n) ",
404404
"InitialBranch": "分支名称? (git的默认值为空): ",
405405
"NoRecentRepositories": "必须在git存储库中打开lazygit。没有有效的最近存储库。即将退出...",
406-
"IncorrectNotARepository": "'notARepository'的值不正确。它应该是“prompt”,“create”,“skip”或“quit”中的一个。",
406+
"IncorrectNotARepository": "'notARepository'的值不正确。它应该是“prompt”,“create”,“recent”,“skip”或“quit”中的一个。",
407407
"AutoStashTitle": "自动存储?",
408408
"AutoStashPrompt": "您必须隐藏并弹出变更以使变更生效。自动执行?(enter/esc)",
409409
"Discard": "查看'放弃变更'选项",

pkg/i18n/translations/zh-TW.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@
281281
"BareRepo": "你嘗試在裸版本庫中開啟 Lazygit,但 Lazygit 尚未支援裸版本庫。是否開啟最新版本庫? (y/n) ",
282282
"InitialBranch": "分支名稱?(留空使用 git 的預設值):",
283283
"NoRecentRepositories": "必須在 git 版本庫中開啟 lazygit。沒有有效的最近版本庫。退出。",
284-
"IncorrectNotARepository": "無效 `notARepository` 輸入。輸入應為「prompt」、「create」、「skip」、或「quit」。",
284+
"IncorrectNotARepository": "無效 `notARepository` 輸入。輸入應為「prompt」、「create」、「recent」、「skip」、或「quit」。",
285285
"AutoStashTitle": "是否自動收藏?",
286286
"AutoStashPrompt": "必須收藏並拾起變更才得以繼續操作。是否自動執行?(Enter/Esc)",
287287
"Discard": "捨棄",

0 commit comments

Comments
 (0)