From b6a5e9d615f0fee7d76f5db33ff48bf32f0ef98b Mon Sep 17 00:00:00 2001 From: Jesse Duffield Date: Sat, 23 Oct 2021 09:52:19 +1100 Subject: [PATCH] use cached git config --- pkg/app/app.go | 22 +-- pkg/commands/config.go | 18 +-- pkg/commands/config_test.go | 70 --------- pkg/commands/dummies.go | 11 +- pkg/commands/files.go | 2 +- pkg/commands/files_test.go | 66 +++------ pkg/commands/git.go | 37 ++--- pkg/commands/git_config/cached_git_config.go | 59 ++++++++ .../git_config/cached_git_config_test.go | 116 +++++++++++++++ pkg/commands/git_config/fake_git_config.go | 22 +++ .../{gitconfig.go => git_config/get_key.go} | 2 +- pkg/commands/git_test.go | 3 +- pkg/commands/loading_files.go | 2 +- pkg/commands/pull_request_default_test.go | 6 +- pkg/commands/pull_request_windows_test.go | 6 +- pkg/commands/remotes.go | 2 +- pkg/commands/sync.go | 4 - pkg/commands/sync_test.go | 134 ++++-------------- pkg/gui/recent_repos_panel.go | 3 +- .../expected/.git_keep/COMMIT_EDITMSG | 1 + .../expected/.git_keep/FETCH_HEAD | 1 + .../pushFollowTags/expected/.git_keep/HEAD | 1 + .../pushFollowTags/expected/.git_keep/config | 18 +++ .../expected/.git_keep/description | 1 + .../pushFollowTags/expected/.git_keep/index | Bin 0 -> 281 bytes .../expected/.git_keep/info/exclude | 7 + .../expected/.git_keep/logs/HEAD | 3 + .../expected/.git_keep/logs/refs/heads/master | 3 + .../.git_keep/logs/refs/remotes/origin/master | 2 + .../0e/6cf0a6b79e8d44e186d812a1f74b43d64fac52 | Bin 0 -> 52 bytes .../18/0cf8328022becee9aaa2577a8f84ea2b9f3827 | Bin 0 -> 21 bytes .../2b/173c861df433fa43ffad13f80c8b312c5c8bce | Bin 0 -> 103 bytes .../34/10e6811881ccede9ff762c875f9b99a3e6eaef | Bin 0 -> 126 bytes .../a5/bce3fd2565d8f458555a0c6f42d0504a848bd5 | Bin 0 -> 21 bytes .../a7/341a59f0ddeef969e69fb6368266d22b0f2416 | Bin 0 -> 77 bytes .../ae/a6b2960cc3e7a2453ce3490ca09d090d7ce223 | Bin 0 -> 149 bytes .../d0/d3bfe09c1a5a9631f3041a184d6b9c6d927c83 | 4 + .../df/6b0d2bcc76e6ec0fca20c227104a4f28bac41b | Bin 0 -> 21 bytes .../f2/7af92910b10e6ddf592fae975337355579464b | 2 + .../expected/.git_keep/refs/heads/master | 1 + .../.git_keep/refs/remotes/origin/master | 1 + .../expected/.git_keep/refs/tags/v1.0 | 1 + .../pushFollowTags/expected/myfile1 | 1 + .../pushFollowTags/expected/myfile2 | 1 + .../pushFollowTags/expected/myfile3 | 1 + .../pushFollowTags/expected_remote/HEAD | 1 + .../pushFollowTags/expected_remote/config | 8 ++ .../expected_remote/description | 1 + .../expected_remote/info/exclude | 7 + .../0e/6cf0a6b79e8d44e186d812a1f74b43d64fac52 | Bin 0 -> 52 bytes .../18/0cf8328022becee9aaa2577a8f84ea2b9f3827 | Bin 0 -> 21 bytes .../2b/173c861df433fa43ffad13f80c8b312c5c8bce | Bin 0 -> 103 bytes .../34/10e6811881ccede9ff762c875f9b99a3e6eaef | Bin 0 -> 126 bytes .../a5/bce3fd2565d8f458555a0c6f42d0504a848bd5 | Bin 0 -> 21 bytes .../a7/341a59f0ddeef969e69fb6368266d22b0f2416 | Bin 0 -> 77 bytes .../ae/a6b2960cc3e7a2453ce3490ca09d090d7ce223 | Bin 0 -> 149 bytes .../d0/d3bfe09c1a5a9631f3041a184d6b9c6d927c83 | 4 + .../df/6b0d2bcc76e6ec0fca20c227104a4f28bac41b | Bin 0 -> 21 bytes .../f2/7af92910b10e6ddf592fae975337355579464b | 2 + .../expected_remote/packed-refs | 2 + .../expected_remote/refs/heads/master | 1 + .../expected_remote/refs/tags/v1.0 | 1 + .../integration/pushFollowTags/recording.json | 1 + test/integration/pushFollowTags/setup.sh | 32 +++++ test/integration/pushFollowTags/test.json | 1 + .../expected/.git_keep/COMMIT_EDITMSG | 1 + .../expected/.git_keep/FETCH_HEAD | 1 + .../pushNoFollowTags/expected/.git_keep/HEAD | 1 + .../expected/.git_keep/config | 16 +++ .../expected/.git_keep/description | 1 + .../pushNoFollowTags/expected/.git_keep/index | Bin 0 -> 281 bytes .../expected/.git_keep/info/exclude | 7 + .../expected/.git_keep/logs/HEAD | 3 + .../expected/.git_keep/logs/refs/heads/master | 3 + .../.git_keep/logs/refs/remotes/origin/master | 2 + .../03/009ca2af4be2a9bb49206974ce9c97eaa2da23 | Bin 0 -> 148 bytes .../0e/6cf0a6b79e8d44e186d812a1f74b43d64fac52 | Bin 0 -> 52 bytes .../18/0cf8328022becee9aaa2577a8f84ea2b9f3827 | Bin 0 -> 21 bytes .../2b/173c861df433fa43ffad13f80c8b312c5c8bce | Bin 0 -> 103 bytes .../8f/99b05bf3462e1a797335475bff5fabe3ae9ec5 | 3 + .../a5/bce3fd2565d8f458555a0c6f42d0504a848bd5 | Bin 0 -> 21 bytes .../a7/341a59f0ddeef969e69fb6368266d22b0f2416 | Bin 0 -> 77 bytes .../df/6b0d2bcc76e6ec0fca20c227104a4f28bac41b | Bin 0 -> 21 bytes .../e1/9bd88e6b3a0d7e4ffc1de39b34d5a312fb9b77 | Bin 0 -> 127 bytes .../fb/20b9e96648c61699f9faf3a4383340fefd5f91 | 3 + .../expected/.git_keep/refs/heads/master | 1 + .../.git_keep/refs/remotes/origin/master | 1 + .../expected/.git_keep/refs/tags/v1.0 | 1 + .../pushNoFollowTags/expected/myfile1 | 1 + .../pushNoFollowTags/expected/myfile2 | 1 + .../pushNoFollowTags/expected/myfile3 | 1 + .../pushNoFollowTags/expected_remote/HEAD | 1 + .../pushNoFollowTags/expected_remote/config | 8 ++ .../expected_remote/description | 1 + .../expected_remote/info/exclude | 7 + .../03/009ca2af4be2a9bb49206974ce9c97eaa2da23 | Bin 0 -> 148 bytes .../0e/6cf0a6b79e8d44e186d812a1f74b43d64fac52 | Bin 0 -> 52 bytes .../18/0cf8328022becee9aaa2577a8f84ea2b9f3827 | Bin 0 -> 21 bytes .../2b/173c861df433fa43ffad13f80c8b312c5c8bce | Bin 0 -> 103 bytes .../8f/99b05bf3462e1a797335475bff5fabe3ae9ec5 | 3 + .../a5/bce3fd2565d8f458555a0c6f42d0504a848bd5 | Bin 0 -> 21 bytes .../a7/341a59f0ddeef969e69fb6368266d22b0f2416 | Bin 0 -> 77 bytes .../df/6b0d2bcc76e6ec0fca20c227104a4f28bac41b | Bin 0 -> 21 bytes .../fb/20b9e96648c61699f9faf3a4383340fefd5f91 | 3 + .../expected_remote/packed-refs | 2 + .../expected_remote/refs/heads/master | 1 + .../pushNoFollowTags/recording.json | 1 + test/integration/pushNoFollowTags/setup.sh | 31 ++++ test/integration/pushNoFollowTags/test.json | 1 + .../pushTag/expected/.git_keep/COMMIT_EDITMSG | 1 + .../pushTag/expected/.git_keep/FETCH_HEAD | 1 + .../pushTag/expected/.git_keep/HEAD | 1 + .../pushTag/expected/.git_keep/config | 16 +++ .../pushTag/expected/.git_keep/description | 1 + .../pushTag/expected/.git_keep/index | Bin 0 -> 209 bytes .../pushTag/expected/.git_keep/info/exclude | 7 + .../pushTag/expected/.git_keep/logs/HEAD | 2 + .../expected/.git_keep/logs/refs/heads/master | 2 + .../.git_keep/logs/refs/remotes/origin/master | 1 + .../0e/6cf0a6b79e8d44e186d812a1f74b43d64fac52 | Bin 0 -> 52 bytes .../18/0cf8328022becee9aaa2577a8f84ea2b9f3827 | Bin 0 -> 21 bytes .../90/5961711d3f0898c003c7e4da636a4c683f7934 | Bin 0 -> 119 bytes .../96/39a47a7955a338919b090835305898ea516c66 | Bin 0 -> 149 bytes .../a5/bce3fd2565d8f458555a0c6f42d0504a848bd5 | Bin 0 -> 21 bytes .../a7/341a59f0ddeef969e69fb6368266d22b0f2416 | Bin 0 -> 77 bytes .../expected/.git_keep/refs/heads/master | 1 + .../.git_keep/refs/remotes/origin/master | 1 + .../pushTag/expected/.git_keep/refs/tags/v1.0 | 1 + test/integration/pushTag/expected/myfile1 | 1 + test/integration/pushTag/expected/myfile2 | 1 + test/integration/pushTag/expected_remote/HEAD | 1 + .../pushTag/expected_remote/config | 8 ++ .../pushTag/expected_remote/description | 1 + .../pushTag/expected_remote/info/exclude | 7 + .../0e/6cf0a6b79e8d44e186d812a1f74b43d64fac52 | Bin 0 -> 52 bytes .../18/0cf8328022becee9aaa2577a8f84ea2b9f3827 | Bin 0 -> 21 bytes .../90/5961711d3f0898c003c7e4da636a4c683f7934 | Bin 0 -> 119 bytes .../96/39a47a7955a338919b090835305898ea516c66 | Bin 0 -> 149 bytes .../a5/bce3fd2565d8f458555a0c6f42d0504a848bd5 | Bin 0 -> 21 bytes .../a7/341a59f0ddeef969e69fb6368266d22b0f2416 | Bin 0 -> 77 bytes .../pushTag/expected_remote/packed-refs | 2 + .../pushTag/expected_remote/refs/tags/v1.0 | 1 + test/integration/pushTag/recording.json | 1 + test/integration/pushTag/setup.sh | 26 ++++ test/integration/pushTag/test.json | 1 + 145 files changed, 596 insertions(+), 290 deletions(-) delete mode 100644 pkg/commands/config_test.go create mode 100644 pkg/commands/git_config/cached_git_config.go create mode 100644 pkg/commands/git_config/cached_git_config_test.go create mode 100644 pkg/commands/git_config/fake_git_config.go rename pkg/commands/{gitconfig.go => git_config/get_key.go} (99%) create mode 100644 test/integration/pushFollowTags/expected/.git_keep/COMMIT_EDITMSG create mode 100644 test/integration/pushFollowTags/expected/.git_keep/FETCH_HEAD create mode 100644 test/integration/pushFollowTags/expected/.git_keep/HEAD create mode 100644 test/integration/pushFollowTags/expected/.git_keep/config create mode 100644 test/integration/pushFollowTags/expected/.git_keep/description create mode 100644 test/integration/pushFollowTags/expected/.git_keep/index create mode 100644 test/integration/pushFollowTags/expected/.git_keep/info/exclude create mode 100644 test/integration/pushFollowTags/expected/.git_keep/logs/HEAD create mode 100644 test/integration/pushFollowTags/expected/.git_keep/logs/refs/heads/master create mode 100644 test/integration/pushFollowTags/expected/.git_keep/logs/refs/remotes/origin/master create mode 100644 test/integration/pushFollowTags/expected/.git_keep/objects/0e/6cf0a6b79e8d44e186d812a1f74b43d64fac52 create mode 100644 test/integration/pushFollowTags/expected/.git_keep/objects/18/0cf8328022becee9aaa2577a8f84ea2b9f3827 create mode 100644 test/integration/pushFollowTags/expected/.git_keep/objects/2b/173c861df433fa43ffad13f80c8b312c5c8bce create mode 100644 test/integration/pushFollowTags/expected/.git_keep/objects/34/10e6811881ccede9ff762c875f9b99a3e6eaef create mode 100644 test/integration/pushFollowTags/expected/.git_keep/objects/a5/bce3fd2565d8f458555a0c6f42d0504a848bd5 create mode 100644 test/integration/pushFollowTags/expected/.git_keep/objects/a7/341a59f0ddeef969e69fb6368266d22b0f2416 create mode 100644 test/integration/pushFollowTags/expected/.git_keep/objects/ae/a6b2960cc3e7a2453ce3490ca09d090d7ce223 create mode 100644 test/integration/pushFollowTags/expected/.git_keep/objects/d0/d3bfe09c1a5a9631f3041a184d6b9c6d927c83 create mode 100644 test/integration/pushFollowTags/expected/.git_keep/objects/df/6b0d2bcc76e6ec0fca20c227104a4f28bac41b create mode 100644 test/integration/pushFollowTags/expected/.git_keep/objects/f2/7af92910b10e6ddf592fae975337355579464b create mode 100644 test/integration/pushFollowTags/expected/.git_keep/refs/heads/master create mode 100644 test/integration/pushFollowTags/expected/.git_keep/refs/remotes/origin/master create mode 100644 test/integration/pushFollowTags/expected/.git_keep/refs/tags/v1.0 create mode 100644 test/integration/pushFollowTags/expected/myfile1 create mode 100644 test/integration/pushFollowTags/expected/myfile2 create mode 100644 test/integration/pushFollowTags/expected/myfile3 create mode 100644 test/integration/pushFollowTags/expected_remote/HEAD create mode 100644 test/integration/pushFollowTags/expected_remote/config create mode 100644 test/integration/pushFollowTags/expected_remote/description create mode 100644 test/integration/pushFollowTags/expected_remote/info/exclude create mode 100644 test/integration/pushFollowTags/expected_remote/objects/0e/6cf0a6b79e8d44e186d812a1f74b43d64fac52 create mode 100644 test/integration/pushFollowTags/expected_remote/objects/18/0cf8328022becee9aaa2577a8f84ea2b9f3827 create mode 100644 test/integration/pushFollowTags/expected_remote/objects/2b/173c861df433fa43ffad13f80c8b312c5c8bce create mode 100644 test/integration/pushFollowTags/expected_remote/objects/34/10e6811881ccede9ff762c875f9b99a3e6eaef create mode 100644 test/integration/pushFollowTags/expected_remote/objects/a5/bce3fd2565d8f458555a0c6f42d0504a848bd5 create mode 100644 test/integration/pushFollowTags/expected_remote/objects/a7/341a59f0ddeef969e69fb6368266d22b0f2416 create mode 100644 test/integration/pushFollowTags/expected_remote/objects/ae/a6b2960cc3e7a2453ce3490ca09d090d7ce223 create mode 100644 test/integration/pushFollowTags/expected_remote/objects/d0/d3bfe09c1a5a9631f3041a184d6b9c6d927c83 create mode 100644 test/integration/pushFollowTags/expected_remote/objects/df/6b0d2bcc76e6ec0fca20c227104a4f28bac41b create mode 100644 test/integration/pushFollowTags/expected_remote/objects/f2/7af92910b10e6ddf592fae975337355579464b create mode 100644 test/integration/pushFollowTags/expected_remote/packed-refs create mode 100644 test/integration/pushFollowTags/expected_remote/refs/heads/master create mode 100644 test/integration/pushFollowTags/expected_remote/refs/tags/v1.0 create mode 100644 test/integration/pushFollowTags/recording.json create mode 100644 test/integration/pushFollowTags/setup.sh create mode 100644 test/integration/pushFollowTags/test.json create mode 100644 test/integration/pushNoFollowTags/expected/.git_keep/COMMIT_EDITMSG create mode 100644 test/integration/pushNoFollowTags/expected/.git_keep/FETCH_HEAD create mode 100644 test/integration/pushNoFollowTags/expected/.git_keep/HEAD create mode 100644 test/integration/pushNoFollowTags/expected/.git_keep/config create mode 100644 test/integration/pushNoFollowTags/expected/.git_keep/description create mode 100644 test/integration/pushNoFollowTags/expected/.git_keep/index create mode 100644 test/integration/pushNoFollowTags/expected/.git_keep/info/exclude create mode 100644 test/integration/pushNoFollowTags/expected/.git_keep/logs/HEAD create mode 100644 test/integration/pushNoFollowTags/expected/.git_keep/logs/refs/heads/master create mode 100644 test/integration/pushNoFollowTags/expected/.git_keep/logs/refs/remotes/origin/master create mode 100644 test/integration/pushNoFollowTags/expected/.git_keep/objects/03/009ca2af4be2a9bb49206974ce9c97eaa2da23 create mode 100644 test/integration/pushNoFollowTags/expected/.git_keep/objects/0e/6cf0a6b79e8d44e186d812a1f74b43d64fac52 create mode 100644 test/integration/pushNoFollowTags/expected/.git_keep/objects/18/0cf8328022becee9aaa2577a8f84ea2b9f3827 create mode 100644 test/integration/pushNoFollowTags/expected/.git_keep/objects/2b/173c861df433fa43ffad13f80c8b312c5c8bce create mode 100644 test/integration/pushNoFollowTags/expected/.git_keep/objects/8f/99b05bf3462e1a797335475bff5fabe3ae9ec5 create mode 100644 test/integration/pushNoFollowTags/expected/.git_keep/objects/a5/bce3fd2565d8f458555a0c6f42d0504a848bd5 create mode 100644 test/integration/pushNoFollowTags/expected/.git_keep/objects/a7/341a59f0ddeef969e69fb6368266d22b0f2416 create mode 100644 test/integration/pushNoFollowTags/expected/.git_keep/objects/df/6b0d2bcc76e6ec0fca20c227104a4f28bac41b create mode 100644 test/integration/pushNoFollowTags/expected/.git_keep/objects/e1/9bd88e6b3a0d7e4ffc1de39b34d5a312fb9b77 create mode 100644 test/integration/pushNoFollowTags/expected/.git_keep/objects/fb/20b9e96648c61699f9faf3a4383340fefd5f91 create mode 100644 test/integration/pushNoFollowTags/expected/.git_keep/refs/heads/master create mode 100644 test/integration/pushNoFollowTags/expected/.git_keep/refs/remotes/origin/master create mode 100644 test/integration/pushNoFollowTags/expected/.git_keep/refs/tags/v1.0 create mode 100644 test/integration/pushNoFollowTags/expected/myfile1 create mode 100644 test/integration/pushNoFollowTags/expected/myfile2 create mode 100644 test/integration/pushNoFollowTags/expected/myfile3 create mode 100644 test/integration/pushNoFollowTags/expected_remote/HEAD create mode 100644 test/integration/pushNoFollowTags/expected_remote/config create mode 100644 test/integration/pushNoFollowTags/expected_remote/description create mode 100644 test/integration/pushNoFollowTags/expected_remote/info/exclude create mode 100644 test/integration/pushNoFollowTags/expected_remote/objects/03/009ca2af4be2a9bb49206974ce9c97eaa2da23 create mode 100644 test/integration/pushNoFollowTags/expected_remote/objects/0e/6cf0a6b79e8d44e186d812a1f74b43d64fac52 create mode 100644 test/integration/pushNoFollowTags/expected_remote/objects/18/0cf8328022becee9aaa2577a8f84ea2b9f3827 create mode 100644 test/integration/pushNoFollowTags/expected_remote/objects/2b/173c861df433fa43ffad13f80c8b312c5c8bce create mode 100644 test/integration/pushNoFollowTags/expected_remote/objects/8f/99b05bf3462e1a797335475bff5fabe3ae9ec5 create mode 100644 test/integration/pushNoFollowTags/expected_remote/objects/a5/bce3fd2565d8f458555a0c6f42d0504a848bd5 create mode 100644 test/integration/pushNoFollowTags/expected_remote/objects/a7/341a59f0ddeef969e69fb6368266d22b0f2416 create mode 100644 test/integration/pushNoFollowTags/expected_remote/objects/df/6b0d2bcc76e6ec0fca20c227104a4f28bac41b create mode 100644 test/integration/pushNoFollowTags/expected_remote/objects/fb/20b9e96648c61699f9faf3a4383340fefd5f91 create mode 100644 test/integration/pushNoFollowTags/expected_remote/packed-refs create mode 100644 test/integration/pushNoFollowTags/expected_remote/refs/heads/master create mode 100644 test/integration/pushNoFollowTags/recording.json create mode 100644 test/integration/pushNoFollowTags/setup.sh create mode 100644 test/integration/pushNoFollowTags/test.json create mode 100644 test/integration/pushTag/expected/.git_keep/COMMIT_EDITMSG create mode 100644 test/integration/pushTag/expected/.git_keep/FETCH_HEAD create mode 100644 test/integration/pushTag/expected/.git_keep/HEAD create mode 100644 test/integration/pushTag/expected/.git_keep/config create mode 100644 test/integration/pushTag/expected/.git_keep/description create mode 100644 test/integration/pushTag/expected/.git_keep/index create mode 100644 test/integration/pushTag/expected/.git_keep/info/exclude create mode 100644 test/integration/pushTag/expected/.git_keep/logs/HEAD create mode 100644 test/integration/pushTag/expected/.git_keep/logs/refs/heads/master create mode 100644 test/integration/pushTag/expected/.git_keep/logs/refs/remotes/origin/master create mode 100644 test/integration/pushTag/expected/.git_keep/objects/0e/6cf0a6b79e8d44e186d812a1f74b43d64fac52 create mode 100644 test/integration/pushTag/expected/.git_keep/objects/18/0cf8328022becee9aaa2577a8f84ea2b9f3827 create mode 100644 test/integration/pushTag/expected/.git_keep/objects/90/5961711d3f0898c003c7e4da636a4c683f7934 create mode 100644 test/integration/pushTag/expected/.git_keep/objects/96/39a47a7955a338919b090835305898ea516c66 create mode 100644 test/integration/pushTag/expected/.git_keep/objects/a5/bce3fd2565d8f458555a0c6f42d0504a848bd5 create mode 100644 test/integration/pushTag/expected/.git_keep/objects/a7/341a59f0ddeef969e69fb6368266d22b0f2416 create mode 100644 test/integration/pushTag/expected/.git_keep/refs/heads/master create mode 100644 test/integration/pushTag/expected/.git_keep/refs/remotes/origin/master create mode 100644 test/integration/pushTag/expected/.git_keep/refs/tags/v1.0 create mode 100644 test/integration/pushTag/expected/myfile1 create mode 100644 test/integration/pushTag/expected/myfile2 create mode 100644 test/integration/pushTag/expected_remote/HEAD create mode 100644 test/integration/pushTag/expected_remote/config create mode 100644 test/integration/pushTag/expected_remote/description create mode 100644 test/integration/pushTag/expected_remote/info/exclude create mode 100644 test/integration/pushTag/expected_remote/objects/0e/6cf0a6b79e8d44e186d812a1f74b43d64fac52 create mode 100644 test/integration/pushTag/expected_remote/objects/18/0cf8328022becee9aaa2577a8f84ea2b9f3827 create mode 100644 test/integration/pushTag/expected_remote/objects/90/5961711d3f0898c003c7e4da636a4c683f7934 create mode 100644 test/integration/pushTag/expected_remote/objects/96/39a47a7955a338919b090835305898ea516c66 create mode 100644 test/integration/pushTag/expected_remote/objects/a5/bce3fd2565d8f458555a0c6f42d0504a848bd5 create mode 100644 test/integration/pushTag/expected_remote/objects/a7/341a59f0ddeef969e69fb6368266d22b0f2416 create mode 100644 test/integration/pushTag/expected_remote/packed-refs create mode 100644 test/integration/pushTag/expected_remote/refs/tags/v1.0 create mode 100644 test/integration/pushTag/recording.json create mode 100644 test/integration/pushTag/setup.sh create mode 100644 test/integration/pushTag/test.json diff --git a/pkg/app/app.go b/pkg/app/app.go index e1d30d841..bb7485cca 100644 --- a/pkg/app/app.go +++ b/pkg/app/app.go @@ -4,15 +4,6 @@ import ( "bufio" "errors" "fmt" - "github.com/aybabtme/humanlog" - "github.com/jesseduffield/lazygit/pkg/commands" - "github.com/jesseduffield/lazygit/pkg/commands/oscommands" - "github.com/jesseduffield/lazygit/pkg/config" - "github.com/jesseduffield/lazygit/pkg/env" - "github.com/jesseduffield/lazygit/pkg/gui" - "github.com/jesseduffield/lazygit/pkg/i18n" - "github.com/jesseduffield/lazygit/pkg/updates" - "github.com/sirupsen/logrus" "io" "io/ioutil" "log" @@ -21,6 +12,17 @@ import ( "regexp" "strconv" "strings" + + "github.com/aybabtme/humanlog" + "github.com/jesseduffield/lazygit/pkg/commands" + "github.com/jesseduffield/lazygit/pkg/commands/git_config" + "github.com/jesseduffield/lazygit/pkg/commands/oscommands" + "github.com/jesseduffield/lazygit/pkg/config" + "github.com/jesseduffield/lazygit/pkg/env" + "github.com/jesseduffield/lazygit/pkg/gui" + "github.com/jesseduffield/lazygit/pkg/i18n" + "github.com/jesseduffield/lazygit/pkg/updates" + "github.com/sirupsen/logrus" ) // App struct @@ -125,7 +127,7 @@ func NewApp(config config.AppConfigurer, filterPath string) (*App, error) { return app, err } - app.GitCommand, err = commands.NewGitCommand(app.Log, app.OSCommand, app.Tr, app.Config) + app.GitCommand, err = commands.NewGitCommand(app.Log, app.OSCommand, app.Tr, app.Config, git_config.NewStdCachedGitConfig(app.Log)) if err != nil { return app, err } diff --git a/pkg/commands/config.go b/pkg/commands/config.go index 9600c3403..922e4f580 100644 --- a/pkg/commands/config.go +++ b/pkg/commands/config.go @@ -15,12 +15,8 @@ func (c *GitCommand) ConfiguredPager() string { if os.Getenv("PAGER") != "" { return os.Getenv("PAGER") } - output, err := c.RunCommandWithOutput("git config --get-all core.pager") - if err != nil { - return "" - } - trimmedOutput := strings.TrimSpace(output) - return strings.Split(trimmedOutput, "\n")[0] + output := c.GitConfig.Get("core.pager") + return strings.Split(output, "\n")[0] } func (c *GitCommand) GetPager(width int) string { @@ -42,11 +38,6 @@ func (c *GitCommand) colorArg() string { return c.Config.GetUserConfig().Git.Paging.ColorArg } -func (c *GitCommand) GetConfigValue(key string) string { - output, _ := c.getGitConfigValue(key) - return output -} - // UsingGpg tells us whether the user has gpg enabled so that we can know // whether we need to run a subprocess to allow them to enter their password func (c *GitCommand) UsingGpg() bool { @@ -55,8 +46,5 @@ func (c *GitCommand) UsingGpg() bool { return false } - gpgsign := c.GetConfigValue("commit.gpgsign") - value := strings.ToLower(gpgsign) - - return value == "true" || value == "1" || value == "yes" || value == "on" + return c.GitConfig.GetBool("commit.gpgsign") } diff --git a/pkg/commands/config_test.go b/pkg/commands/config_test.go deleted file mode 100644 index c16b53901..000000000 --- a/pkg/commands/config_test.go +++ /dev/null @@ -1,70 +0,0 @@ -package commands - -import ( - "testing" - - "github.com/stretchr/testify/assert" -) - -// TestGitCommandUsingGpg is a function. -func TestGitCommandUsingGpg(t *testing.T) { - type scenario struct { - testName string - getGitConfigValue func(string) (string, error) - test func(bool) - } - - scenarios := []scenario{ - { - "Option global and local config commit.gpgsign is not set", - func(string) (string, error) { return "", nil }, - func(gpgEnabled bool) { - assert.False(t, gpgEnabled) - }, - }, - { - "Option commit.gpgsign is true", - func(string) (string, error) { - return "True", nil - }, - func(gpgEnabled bool) { - assert.True(t, gpgEnabled) - }, - }, - { - "Option commit.gpgsign is on", - func(string) (string, error) { - return "ON", nil - }, - func(gpgEnabled bool) { - assert.True(t, gpgEnabled) - }, - }, - { - "Option commit.gpgsign is yes", - func(string) (string, error) { - return "YeS", nil - }, - func(gpgEnabled bool) { - assert.True(t, gpgEnabled) - }, - }, - { - "Option commit.gpgsign is 1", - func(string) (string, error) { - return "1", nil - }, - func(gpgEnabled bool) { - assert.True(t, gpgEnabled) - }, - }, - } - - for _, s := range scenarios { - t.Run(s.testName, func(t *testing.T) { - gitCmd := NewDummyGitCommand() - gitCmd.getGitConfigValue = s.getGitConfigValue - s.test(gitCmd.UsingGpg()) - }) - } -} diff --git a/pkg/commands/dummies.go b/pkg/commands/dummies.go index b1b6e9441..a8178385d 100644 --- a/pkg/commands/dummies.go +++ b/pkg/commands/dummies.go @@ -1,6 +1,7 @@ package commands import ( + "github.com/jesseduffield/lazygit/pkg/commands/git_config" "github.com/jesseduffield/lazygit/pkg/commands/oscommands" "github.com/jesseduffield/lazygit/pkg/config" "github.com/jesseduffield/lazygit/pkg/i18n" @@ -16,10 +17,10 @@ func NewDummyGitCommand() *GitCommand { func NewDummyGitCommandWithOSCommand(osCommand *oscommands.OSCommand) *GitCommand { newAppConfig := config.NewDummyAppConfig() return &GitCommand{ - Log: utils.NewDummyLog(), - OSCommand: osCommand, - Tr: i18n.NewTranslationSet(utils.NewDummyLog(), newAppConfig.GetUserConfig().Gui.Language), - Config: newAppConfig, - getGitConfigValue: func(string) (string, error) { return "", nil }, + Log: utils.NewDummyLog(), + OSCommand: osCommand, + Tr: i18n.NewTranslationSet(utils.NewDummyLog(), newAppConfig.GetUserConfig().Gui.Language), + Config: newAppConfig, + GitConfig: git_config.NewFakeGitConfig(map[string]string{}), } } diff --git a/pkg/commands/files.go b/pkg/commands/files.go index 462b5b899..07c4c4d28 100644 --- a/pkg/commands/files.go +++ b/pkg/commands/files.go @@ -331,7 +331,7 @@ func (c *GitCommand) EditFileCmdStr(filename string, lineNumber int) (string, er editor := c.Config.GetUserConfig().OS.EditCommand if editor == "" { - editor = c.GetConfigValue("core.editor") + editor = c.GitConfig.Get("core.editor") } if editor == "" { diff --git a/pkg/commands/files_test.go b/pkg/commands/files_test.go index 0d718a7bf..f72b47ca0 100644 --- a/pkg/commands/files_test.go +++ b/pkg/commands/files_test.go @@ -6,6 +6,7 @@ import ( "os/exec" "testing" + "github.com/jesseduffield/lazygit/pkg/commands/git_config" "github.com/jesseduffield/lazygit/pkg/commands/models" "github.com/jesseduffield/lazygit/pkg/secureexec" "github.com/jesseduffield/lazygit/pkg/test" @@ -523,24 +524,21 @@ func TestGitCommandApplyPatch(t *testing.T) { } } -// TestGitCommandDiscardOldFileChanges is a function. func TestGitCommandDiscardOldFileChanges(t *testing.T) { type scenario struct { - testName string - getGitConfigValue func(string) (string, error) - commits []*models.Commit - commitIndex int - fileName string - command func(string, ...string) *exec.Cmd - test func(error) + testName string + gitConfigMockResponses map[string]string + commits []*models.Commit + commitIndex int + fileName string + command func(string, ...string) *exec.Cmd + test func(error) } scenarios := []scenario{ { "returns error when index outside of range of commits", - func(string) (string, error) { - return "", nil - }, + nil, []*models.Commit{}, 0, "test999.txt", @@ -551,9 +549,7 @@ func TestGitCommandDiscardOldFileChanges(t *testing.T) { }, { "returns error when using gpg", - func(string) (string, error) { - return "true", nil - }, + map[string]string{"commit.gpgsign": "true"}, []*models.Commit{{Name: "commit", Sha: "123456"}}, 0, "test999.txt", @@ -564,9 +560,7 @@ func TestGitCommandDiscardOldFileChanges(t *testing.T) { }, { "checks out file if it already existed", - func(string) (string, error) { - return "", nil - }, + nil, []*models.Commit{ {Name: "commit", Sha: "123456"}, {Name: "commit2", Sha: "abcdef"}, @@ -608,7 +602,7 @@ func TestGitCommandDiscardOldFileChanges(t *testing.T) { for _, s := range scenarios { t.Run(s.testName, func(t *testing.T) { gitCmd.OSCommand.Command = s.command - gitCmd.getGitConfigValue = s.getGitConfigValue + gitCmd.GitConfig = git_config.NewFakeGitConfig(s.gitConfigMockResponses) s.test(gitCmd.DiscardOldFileChanges(s.commits, s.commitIndex, s.fileName)) }) } @@ -725,7 +719,7 @@ func TestEditFileCmdStr(t *testing.T) { configEditCommandTemplate string command func(string, ...string) *exec.Cmd getenv func(string) string - getGitConfigValue func(string) (string, error) + gitConfigMockResponses map[string]string test func(string, error) } @@ -740,9 +734,7 @@ func TestEditFileCmdStr(t *testing.T) { func(env string) string { return "" }, - func(cf string) (string, error) { - return "", nil - }, + nil, func(cmdStr string, err error) { assert.EqualError(t, err, "No editor defined in config file, $GIT_EDITOR, $VISUAL, $EDITOR, or git config") }, @@ -758,9 +750,7 @@ func TestEditFileCmdStr(t *testing.T) { func(env string) string { return "" }, - func(cf string) (string, error) { - return "", nil - }, + nil, func(cmdStr string, err error) { assert.NoError(t, err) assert.Equal(t, "nano "+gitCmd.OSCommand.Quote("test"), cmdStr) @@ -777,9 +767,7 @@ func TestEditFileCmdStr(t *testing.T) { func(env string) string { return "" }, - func(cf string) (string, error) { - return "nano", nil - }, + map[string]string{"core.editor": "nano"}, func(cmdStr string, err error) { assert.NoError(t, err) assert.Equal(t, "nano "+gitCmd.OSCommand.Quote("test"), cmdStr) @@ -800,9 +788,7 @@ func TestEditFileCmdStr(t *testing.T) { return "" }, - func(cf string) (string, error) { - return "", nil - }, + nil, func(cmdStr string, err error) { assert.NoError(t, err) }, @@ -822,9 +808,7 @@ func TestEditFileCmdStr(t *testing.T) { return "" }, - func(cf string) (string, error) { - return "", nil - }, + nil, func(cmdStr string, err error) { assert.NoError(t, err) assert.Equal(t, "emacs "+gitCmd.OSCommand.Quote("test"), cmdStr) @@ -841,9 +825,7 @@ func TestEditFileCmdStr(t *testing.T) { func(env string) string { return "" }, - func(cf string) (string, error) { - return "", nil - }, + nil, func(cmdStr string, err error) { assert.NoError(t, err) assert.Equal(t, "vi "+gitCmd.OSCommand.Quote("test"), cmdStr) @@ -860,9 +842,7 @@ func TestEditFileCmdStr(t *testing.T) { func(env string) string { return "" }, - func(cf string) (string, error) { - return "", nil - }, + nil, func(cmdStr string, err error) { assert.NoError(t, err) assert.Equal(t, "vi "+gitCmd.OSCommand.Quote("file/with space"), cmdStr) @@ -879,9 +859,7 @@ func TestEditFileCmdStr(t *testing.T) { func(env string) string { return "" }, - func(cf string) (string, error) { - return "", nil - }, + nil, func(cmdStr string, err error) { assert.NoError(t, err) assert.Equal(t, "vim +1 "+gitCmd.OSCommand.Quote("open file/at line"), cmdStr) @@ -894,7 +872,7 @@ func TestEditFileCmdStr(t *testing.T) { gitCmd.Config.GetUserConfig().OS.EditCommandTemplate = s.configEditCommandTemplate gitCmd.OSCommand.Command = s.command gitCmd.OSCommand.Getenv = s.getenv - gitCmd.getGitConfigValue = s.getGitConfigValue + gitCmd.GitConfig = git_config.NewFakeGitConfig(s.gitConfigMockResponses) s.test(gitCmd.EditFileCmdStr(s.filename, 1)) } } diff --git a/pkg/commands/git.go b/pkg/commands/git.go index de7569d81..a1a925de7 100644 --- a/pkg/commands/git.go +++ b/pkg/commands/git.go @@ -10,6 +10,7 @@ import ( "github.com/go-errors/errors" gogit "github.com/jesseduffield/go-git/v5" + "github.com/jesseduffield/lazygit/pkg/commands/git_config" "github.com/jesseduffield/lazygit/pkg/commands/oscommands" "github.com/jesseduffield/lazygit/pkg/commands/patch" "github.com/jesseduffield/lazygit/pkg/config" @@ -32,32 +33,32 @@ type GitCommand struct { Repo *gogit.Repository Tr *i18n.TranslationSet Config config.AppConfigurer - getGitConfigValue func(string) (string, error) DotGitDir string onSuccessfulContinue func() error PatchManager *patch.PatchManager + GitConfig git_config.IGitConfig // Push to current determines whether the user has configured to push to the remote branch of the same name as the current or not PushToCurrent bool } // NewGitCommand it runs git commands -func NewGitCommand(log *logrus.Entry, osCommand *oscommands.OSCommand, tr *i18n.TranslationSet, config config.AppConfigurer) (*GitCommand, error) { +func NewGitCommand( + log *logrus.Entry, + osCommand *oscommands.OSCommand, + tr *i18n.TranslationSet, + config config.AppConfigurer, + gitConfig git_config.IGitConfig, +) (*GitCommand, error) { var repo *gogit.Repository - // see what our default push behaviour is - output, err := osCommand.RunCommandWithOutput("git config --get push.default") - pushToCurrent := false - if err != nil { - log.Errorf("error reading git config: %v", err) - } else { - pushToCurrent = strings.TrimSpace(output) == "current" - } + pushToCurrent := gitConfig.Get("push.default") == "current" if err := navigateToRepoRootDirectory(os.Stat, os.Chdir); err != nil { return nil, err } + var err error if repo, err = setupRepository(gogit.PlainOpen, tr.GitconfigParseErr); err != nil { return nil, err } @@ -68,14 +69,14 @@ func NewGitCommand(log *logrus.Entry, osCommand *oscommands.OSCommand, tr *i18n. } gitCommand := &GitCommand{ - Log: log, - OSCommand: osCommand, - Tr: tr, - Repo: repo, - Config: config, - getGitConfigValue: getGitConfigValue, - DotGitDir: dotGitDir, - PushToCurrent: pushToCurrent, + Log: log, + OSCommand: osCommand, + Tr: tr, + Repo: repo, + Config: config, + DotGitDir: dotGitDir, + PushToCurrent: pushToCurrent, + GitConfig: gitConfig, } gitCommand.PatchManager = patch.NewPatchManager(log, gitCommand.ApplyPatch, gitCommand.ShowFileDiff) diff --git a/pkg/commands/git_config/cached_git_config.go b/pkg/commands/git_config/cached_git_config.go new file mode 100644 index 000000000..e2b83bad8 --- /dev/null +++ b/pkg/commands/git_config/cached_git_config.go @@ -0,0 +1,59 @@ +package git_config + +import ( + "strings" + + "github.com/sirupsen/logrus" +) + +type IGitConfig interface { + Get(string) string + GetBool(string) bool +} + +type CachedGitConfig struct { + cache map[string]string + getKey func(string) (string, error) + log *logrus.Entry +} + +func NewStdCachedGitConfig(log *logrus.Entry) *CachedGitConfig { + return NewCachedGitConfig(getGitConfigValue, log) +} + +func NewCachedGitConfig(getKey func(string) (string, error), log *logrus.Entry) *CachedGitConfig { + return &CachedGitConfig{ + cache: make(map[string]string), + getKey: getKey, + log: log, + } +} + +func (self *CachedGitConfig) Get(key string) string { + if value, ok := self.cache[key]; ok { + self.log.Debugf("using cache for key " + key) + return value + } + + value := self.getAux(key) + self.cache[key] = value + return value +} + +func (self *CachedGitConfig) getAux(key string) string { + value, err := self.getKey(key) + if err != nil { + self.log.Debugf("Error getting git config value for key: " + key + ". Error: " + err.Error()) + return "" + } + return strings.TrimSpace(value) +} + +func (self *CachedGitConfig) GetBool(key string) bool { + return isTruthy(self.Get(key)) +} + +func isTruthy(value string) bool { + lcValue := strings.ToLower(value) + return lcValue == "true" || lcValue == "1" || lcValue == "yes" || lcValue == "on" +} diff --git a/pkg/commands/git_config/cached_git_config_test.go b/pkg/commands/git_config/cached_git_config_test.go new file mode 100644 index 000000000..f03535a6e --- /dev/null +++ b/pkg/commands/git_config/cached_git_config_test.go @@ -0,0 +1,116 @@ +package git_config + +import ( + "testing" + + "github.com/jesseduffield/lazygit/pkg/utils" + "github.com/stretchr/testify/assert" +) + +func TestGetBool(t *testing.T) { + type scenario struct { + testName string + mockResponses map[string]string + expected bool + } + + scenarios := []scenario{ + { + "Option global and local config commit.gpgsign is not set", + map[string]string{}, + false, + }, + { + "Some other random key is set", + map[string]string{"blah": "blah"}, + false, + }, + { + "Option commit.gpgsign is true", + map[string]string{"commit.gpgsign": "True"}, + true, + }, + { + "Option commit.gpgsign is on", + map[string]string{"commit.gpgsign": "ON"}, + true, + }, + { + "Option commit.gpgsign is yes", + map[string]string{"commit.gpgsign": "YeS"}, + true, + }, + { + "Option commit.gpgsign is 1", + map[string]string{"commit.gpgsign": "1"}, + true, + }, + } + + for _, s := range scenarios { + s := s + t.Run(s.testName, func(t *testing.T) { + fake := NewFakeGitConfig(s.mockResponses) + real := NewCachedGitConfig( + func(key string) (string, error) { + return fake.Get(key), nil + }, + utils.NewDummyLog(), + ) + result := real.GetBool("commit.gpgsign") + assert.Equal(t, s.expected, result) + }) + } +} + +func TestGet(t *testing.T) { + type scenario struct { + testName string + mockResponses map[string]string + expected string + } + + scenarios := []scenario{ + { + "not set", + map[string]string{}, + "", + }, + { + "is set", + map[string]string{"commit.gpgsign": "blah"}, + "blah", + }, + } + + for _, s := range scenarios { + s := s + t.Run(s.testName, func(t *testing.T) { + fake := NewFakeGitConfig(s.mockResponses) + real := NewCachedGitConfig( + func(key string) (string, error) { + return fake.Get(key), nil + }, + utils.NewDummyLog(), + ) + result := real.Get("commit.gpgsign") + assert.Equal(t, s.expected, result) + }) + } + + // verifying that the cache is used + count := 0 + real := NewCachedGitConfig( + func(key string) (string, error) { + count++ + assert.Equal(t, "commit.gpgsign", key) + return "blah", nil + }, + utils.NewDummyLog(), + ) + result := real.Get("commit.gpgsign") + assert.Equal(t, "blah", result) + result = real.Get("commit.gpgsign") + assert.Equal(t, "blah", result) + assert.Equal(t, 1, count) +} diff --git a/pkg/commands/git_config/fake_git_config.go b/pkg/commands/git_config/fake_git_config.go new file mode 100644 index 000000000..f010efd8c --- /dev/null +++ b/pkg/commands/git_config/fake_git_config.go @@ -0,0 +1,22 @@ +package git_config + +type FakeGitConfig struct { + mockResponses map[string]string +} + +func NewFakeGitConfig(mockResponses map[string]string) *FakeGitConfig { + return &FakeGitConfig{ + mockResponses: mockResponses, + } +} + +func (self *FakeGitConfig) Get(key string) string { + if self.mockResponses == nil { + return "" + } + return self.mockResponses[key] +} + +func (self *FakeGitConfig) GetBool(key string) bool { + return isTruthy(self.Get(key)) +} diff --git a/pkg/commands/gitconfig.go b/pkg/commands/git_config/get_key.go similarity index 99% rename from pkg/commands/gitconfig.go rename to pkg/commands/git_config/get_key.go index dbe72c570..85892ea2d 100644 --- a/pkg/commands/gitconfig.go +++ b/pkg/commands/git_config/get_key.go @@ -1,4 +1,4 @@ -package commands +package git_config import ( "bytes" diff --git a/pkg/commands/git_test.go b/pkg/commands/git_test.go index 6891fdc53..19eabd583 100644 --- a/pkg/commands/git_test.go +++ b/pkg/commands/git_test.go @@ -8,6 +8,7 @@ import ( "github.com/go-errors/errors" gogit "github.com/jesseduffield/go-git/v5" + "github.com/jesseduffield/lazygit/pkg/commands/git_config" "github.com/jesseduffield/lazygit/pkg/commands/oscommands" "github.com/jesseduffield/lazygit/pkg/config" "github.com/jesseduffield/lazygit/pkg/i18n" @@ -210,7 +211,7 @@ func TestNewGitCommand(t *testing.T) { t.Run(s.testName, func(t *testing.T) { s.setup() newAppConfig := config.NewDummyAppConfig() - s.test(NewGitCommand(utils.NewDummyLog(), oscommands.NewDummyOSCommand(), i18n.NewTranslationSet(utils.NewDummyLog(), newAppConfig.GetUserConfig().Gui.Language), newAppConfig)) + s.test(NewGitCommand(utils.NewDummyLog(), oscommands.NewDummyOSCommand(), i18n.NewTranslationSet(utils.NewDummyLog(), newAppConfig.GetUserConfig().Gui.Language), newAppConfig, git_config.NewFakeGitConfig(nil))) }) } } diff --git a/pkg/commands/loading_files.go b/pkg/commands/loading_files.go index d3638a724..098948ed4 100644 --- a/pkg/commands/loading_files.go +++ b/pkg/commands/loading_files.go @@ -15,7 +15,7 @@ type GetStatusFileOptions struct { func (c *GitCommand) GetStatusFiles(opts GetStatusFileOptions) []*models.File { // check if config wants us ignoring untracked files - untrackedFilesSetting := c.GetConfigValue("status.showUntrackedFiles") + untrackedFilesSetting := c.GitConfig.Get("status.showUntrackedFiles") if untrackedFilesSetting == "" { untrackedFilesSetting = "all" diff --git a/pkg/commands/pull_request_default_test.go b/pkg/commands/pull_request_default_test.go index 7f0a1ba5d..e1ce61a5a 100644 --- a/pkg/commands/pull_request_default_test.go +++ b/pkg/commands/pull_request_default_test.go @@ -8,6 +8,7 @@ import ( "strings" "testing" + "github.com/jesseduffield/lazygit/pkg/commands/git_config" "github.com/jesseduffield/lazygit/pkg/secureexec" "github.com/stretchr/testify/assert" ) @@ -247,10 +248,7 @@ func TestCreatePullRequest(t *testing.T) { "invalid.work.com": "noservice:invalid.work.com", "noservice.work.com": "noservice.work.com", } - gitCommand.getGitConfigValue = func(path string) (string, error) { - assert.Equal(t, path, "remote.origin.url") - return s.remoteUrl, nil - } + gitCommand.GitConfig = git_config.NewFakeGitConfig(map[string]string{"remote.origin.url": s.remoteUrl}) dummyPullRequest := NewPullRequest(gitCommand) s.test(dummyPullRequest.Create(s.from, s.to)) }) diff --git a/pkg/commands/pull_request_windows_test.go b/pkg/commands/pull_request_windows_test.go index b0eee37b8..73e91f157 100644 --- a/pkg/commands/pull_request_windows_test.go +++ b/pkg/commands/pull_request_windows_test.go @@ -8,6 +8,7 @@ import ( "strings" "testing" + "github.com/jesseduffield/lazygit/pkg/commands/git_config" "github.com/jesseduffield/lazygit/pkg/secureexec" "github.com/stretchr/testify/assert" ) @@ -247,10 +248,7 @@ func TestCreatePullRequestOnWindows(t *testing.T) { "invalid.work.com": "noservice:invalid.work.com", "noservice.work.com": "noservice.work.com", } - gitCommand.getGitConfigValue = func(path string) (string, error) { - assert.Equal(t, path, "remote.origin.url") - return s.remoteUrl, nil - } + gitCommand.GitConfig = git_config.NewFakeGitConfig(map[string]string{"remote.origin.url": s.remoteUrl}) dummyPullRequest := NewPullRequest(gitCommand) s.test(dummyPullRequest.Create(s.from, s.to)) }) diff --git a/pkg/commands/remotes.go b/pkg/commands/remotes.go index b56893817..0839f9583 100644 --- a/pkg/commands/remotes.go +++ b/pkg/commands/remotes.go @@ -38,5 +38,5 @@ func (c *GitCommand) CheckRemoteBranchExists(branchName string) bool { // GetRemoteURL returns current repo remote url func (c *GitCommand) GetRemoteURL() string { - return c.GetConfigValue("remote.origin.url") + return c.GitConfig.Get("remote.origin.url") } diff --git a/pkg/commands/sync.go b/pkg/commands/sync.go index 7051f2236..3f94c5f4e 100644 --- a/pkg/commands/sync.go +++ b/pkg/commands/sync.go @@ -18,10 +18,6 @@ type PushOpts struct { func (c *GitCommand) Push(opts PushOpts) error { cmdStr := "git push" - if c.GetConfigValue("push.followTags") != "false" { - cmdStr += " --follow-tags" - } - if opts.Force { cmdStr += " --force-with-lease" } diff --git a/pkg/commands/sync_test.go b/pkg/commands/sync_test.go index f793639be..924bd56ef 100644 --- a/pkg/commands/sync_test.go +++ b/pkg/commands/sync_test.go @@ -11,11 +11,10 @@ import ( // TestGitCommandPush is a function. func TestGitCommandPush(t *testing.T) { type scenario struct { - testName string - getGitConfigValue func(string) (string, error) - command func(string, ...string) *exec.Cmd - opts PushOpts - test func(error) + testName string + command func(string, ...string) *exec.Cmd + opts PushOpts + test func(error) } prompt := func(passOrUname string) string { @@ -24,42 +23,7 @@ func TestGitCommandPush(t *testing.T) { scenarios := []scenario{ { - "Push with force disabled, follow-tags on", - func(string) (string, error) { - return "", nil - }, - func(cmd string, args ...string) *exec.Cmd { - assert.EqualValues(t, "git", cmd) - assert.EqualValues(t, []string{"push", "--follow-tags"}, args) - - return secureexec.Command("echo") - }, - PushOpts{Force: false, PromptUserForCredential: prompt}, - func(err error) { - assert.NoError(t, err) - }, - }, - { - "Push with force enabled, follow-tags on", - func(string) (string, error) { - return "", nil - }, - func(cmd string, args ...string) *exec.Cmd { - assert.EqualValues(t, "git", cmd) - assert.EqualValues(t, []string{"push", "--follow-tags", "--force-with-lease"}, args) - - return secureexec.Command("echo") - }, - PushOpts{Force: true, PromptUserForCredential: prompt}, - func(err error) { - assert.NoError(t, err) - }, - }, - { - "Push with force disabled, follow-tags off", - func(string) (string, error) { - return "false", nil - }, + "Push with force disabled", func(cmd string, args ...string) *exec.Cmd { assert.EqualValues(t, "git", cmd) assert.EqualValues(t, []string{"push"}, args) @@ -72,13 +36,23 @@ func TestGitCommandPush(t *testing.T) { }, }, { - "Push with an error occurring, follow-tags on", - func(string) (string, error) { - return "", nil - }, + "Push with force enabled", func(cmd string, args ...string) *exec.Cmd { assert.EqualValues(t, "git", cmd) - assert.EqualValues(t, []string{"push", "--follow-tags"}, args) + assert.EqualValues(t, []string{"push", "--force-with-lease"}, args) + + return secureexec.Command("echo") + }, + PushOpts{Force: true, PromptUserForCredential: prompt}, + func(err error) { + assert.NoError(t, err) + }, + }, + { + "Push with an error occurring", + func(cmd string, args ...string) *exec.Cmd { + assert.EqualValues(t, "git", cmd) + assert.EqualValues(t, []string{"push"}, args) return secureexec.Command("test") }, PushOpts{Force: false, PromptUserForCredential: prompt}, @@ -87,10 +61,7 @@ func TestGitCommandPush(t *testing.T) { }, }, { - "Push with force disabled, follow-tags off, upstream supplied", - func(string) (string, error) { - return "false", nil - }, + "Push with force disabled, upstream supplied", func(cmd string, args ...string) *exec.Cmd { assert.EqualValues(t, "git", cmd) assert.EqualValues(t, []string{"push", "origin", "master"}, args) @@ -108,10 +79,7 @@ func TestGitCommandPush(t *testing.T) { }, }, { - "Push with force disabled, follow-tags off, setting upstream", - func(string) (string, error) { - return "false", nil - }, + "Push with force disabled, setting upstream", func(cmd string, args ...string) *exec.Cmd { assert.EqualValues(t, "git", cmd) assert.EqualValues(t, []string{"push", "--set-upstream", "origin", "master"}, args) @@ -130,10 +98,7 @@ func TestGitCommandPush(t *testing.T) { }, }, { - "Push with force enabled, follow-tags off, setting upstream", - func(string) (string, error) { - return "false", nil - }, + "Push with force enabled, setting upstream", func(cmd string, args ...string) *exec.Cmd { assert.EqualValues(t, "git", cmd) assert.EqualValues(t, []string{"push", "--force-with-lease", "--set-upstream", "origin", "master"}, args) @@ -153,9 +118,6 @@ func TestGitCommandPush(t *testing.T) { }, { "Push with remote branch but no origin", - func(string) (string, error) { - return "false", nil - }, func(cmd string, args ...string) *exec.Cmd { return nil }, @@ -172,10 +134,7 @@ func TestGitCommandPush(t *testing.T) { }, }, { - "Push with force disabled, follow-tags off, upstream supplied", - func(string) (string, error) { - return "false", nil - }, + "Push with force disabled, upstream supplied", func(cmd string, args ...string) *exec.Cmd { assert.EqualValues(t, "git", cmd) assert.EqualValues(t, []string{"push", "origin", "master"}, args) @@ -192,57 +151,12 @@ func TestGitCommandPush(t *testing.T) { assert.NoError(t, err) }, }, - { - "Push with force disabled, follow-tags off, setting upstream", - func(string) (string, error) { - return "false", nil - }, - func(cmd string, args ...string) *exec.Cmd { - assert.EqualValues(t, "git", cmd) - assert.EqualValues(t, []string{"push", "--set-upstream", "origin", "master"}, args) - - return secureexec.Command("echo") - }, - PushOpts{ - Force: false, - UpstreamRemote: "origin", - UpstreamBranch: "master", - PromptUserForCredential: prompt, - SetUpstream: true, - }, - func(err error) { - assert.NoError(t, err) - }, - }, - { - "Push with force enabled, follow-tags off, setting upstream", - func(string) (string, error) { - return "false", nil - }, - func(cmd string, args ...string) *exec.Cmd { - assert.EqualValues(t, "git", cmd) - assert.EqualValues(t, []string{"push", "--force-with-lease", "--set-upstream", "origin", "master"}, args) - - return secureexec.Command("echo") - }, - PushOpts{ - Force: true, - UpstreamRemote: "origin", - UpstreamBranch: "master", - PromptUserForCredential: prompt, - SetUpstream: true, - }, - func(err error) { - assert.NoError(t, err) - }, - }, } for _, s := range scenarios { t.Run(s.testName, func(t *testing.T) { gitCmd := NewDummyGitCommand() gitCmd.OSCommand.Command = s.command - gitCmd.getGitConfigValue = s.getGitConfigValue err := gitCmd.Push(s.opts) s.test(err) }) diff --git a/pkg/gui/recent_repos_panel.go b/pkg/gui/recent_repos_panel.go index d1ac4ea30..5460a2155 100644 --- a/pkg/gui/recent_repos_panel.go +++ b/pkg/gui/recent_repos_panel.go @@ -6,6 +6,7 @@ import ( "github.com/jesseduffield/gocui" "github.com/jesseduffield/lazygit/pkg/commands" + "github.com/jesseduffield/lazygit/pkg/commands/git_config" "github.com/jesseduffield/lazygit/pkg/env" "github.com/jesseduffield/lazygit/pkg/gui/style" "github.com/jesseduffield/lazygit/pkg/utils" @@ -72,7 +73,7 @@ func (gui *Gui) dispatchSwitchToRepo(path string, reuse bool) error { return err } - newGitCommand, err := commands.NewGitCommand(gui.Log, gui.OSCommand, gui.Tr, gui.Config) + newGitCommand, err := commands.NewGitCommand(gui.Log, gui.OSCommand, gui.Tr, gui.Config, git_config.NewStdCachedGitConfig(gui.Log)) if err != nil { return err } diff --git a/test/integration/pushFollowTags/expected/.git_keep/COMMIT_EDITMSG b/test/integration/pushFollowTags/expected/.git_keep/COMMIT_EDITMSG new file mode 100644 index 000000000..c23aa0355 --- /dev/null +++ b/test/integration/pushFollowTags/expected/.git_keep/COMMIT_EDITMSG @@ -0,0 +1 @@ +myfile3 diff --git a/test/integration/pushFollowTags/expected/.git_keep/FETCH_HEAD b/test/integration/pushFollowTags/expected/.git_keep/FETCH_HEAD new file mode 100644 index 000000000..eb26084cc --- /dev/null +++ b/test/integration/pushFollowTags/expected/.git_keep/FETCH_HEAD @@ -0,0 +1 @@ +d0d3bfe09c1a5a9631f3041a184d6b9c6d927c83 branch 'master' of ../actual_remote diff --git a/test/integration/pushFollowTags/expected/.git_keep/HEAD b/test/integration/pushFollowTags/expected/.git_keep/HEAD new file mode 100644 index 000000000..cb089cd89 --- /dev/null +++ b/test/integration/pushFollowTags/expected/.git_keep/HEAD @@ -0,0 +1 @@ +ref: refs/heads/master diff --git a/test/integration/pushFollowTags/expected/.git_keep/config b/test/integration/pushFollowTags/expected/.git_keep/config new file mode 100644 index 000000000..190f2591c --- /dev/null +++ b/test/integration/pushFollowTags/expected/.git_keep/config @@ -0,0 +1,18 @@ +[core] + repositoryformatversion = 0 + filemode = true + bare = false + logallrefupdates = true + ignorecase = true + precomposeunicode = true +[user] + email = CI@example.com + name = CI +[remote "origin"] + url = ../actual_remote + fetch = +refs/heads/*:refs/remotes/origin/* +[branch "master"] + remote = origin + merge = refs/heads/master +[push] + followTags = true diff --git a/test/integration/pushFollowTags/expected/.git_keep/description b/test/integration/pushFollowTags/expected/.git_keep/description new file mode 100644 index 000000000..498b267a8 --- /dev/null +++ b/test/integration/pushFollowTags/expected/.git_keep/description @@ -0,0 +1 @@ +Unnamed repository; edit this file 'description' to name the repository. diff --git a/test/integration/pushFollowTags/expected/.git_keep/index b/test/integration/pushFollowTags/expected/.git_keep/index new file mode 100644 index 0000000000000000000000000000000000000000..f23548c757a74abb7e4baa3b8564f7cf7b490c12 GIT binary patch literal 281 zcmZ?q402{*U|<4b=EP!`1SVszn=qP@fq|7V^86bHhQ=if42)laYD9pTZRwuJe^pa& ze2EB+;>mZq5a89)eU*Vdw=yj=C)E(B0HmMUq-!#ahM04K8QmNSo*zaHO8d^eT(u~? zs=wux_IwL 1634944096 +1100 commit (initial): myfile1 +f27af92910b10e6ddf592fae975337355579464b d0d3bfe09c1a5a9631f3041a184d6b9c6d927c83 CI 1634944096 +1100 commit: myfile2 +d0d3bfe09c1a5a9631f3041a184d6b9c6d927c83 aea6b2960cc3e7a2453ce3490ca09d090d7ce223 CI 1634944096 +1100 commit: myfile3 diff --git a/test/integration/pushFollowTags/expected/.git_keep/logs/refs/heads/master b/test/integration/pushFollowTags/expected/.git_keep/logs/refs/heads/master new file mode 100644 index 000000000..263e15735 --- /dev/null +++ b/test/integration/pushFollowTags/expected/.git_keep/logs/refs/heads/master @@ -0,0 +1,3 @@ +0000000000000000000000000000000000000000 f27af92910b10e6ddf592fae975337355579464b CI 1634944096 +1100 commit (initial): myfile1 +f27af92910b10e6ddf592fae975337355579464b d0d3bfe09c1a5a9631f3041a184d6b9c6d927c83 CI 1634944096 +1100 commit: myfile2 +d0d3bfe09c1a5a9631f3041a184d6b9c6d927c83 aea6b2960cc3e7a2453ce3490ca09d090d7ce223 CI 1634944096 +1100 commit: myfile3 diff --git a/test/integration/pushFollowTags/expected/.git_keep/logs/refs/remotes/origin/master b/test/integration/pushFollowTags/expected/.git_keep/logs/refs/remotes/origin/master new file mode 100644 index 000000000..36306f3d0 --- /dev/null +++ b/test/integration/pushFollowTags/expected/.git_keep/logs/refs/remotes/origin/master @@ -0,0 +1,2 @@ +0000000000000000000000000000000000000000 d0d3bfe09c1a5a9631f3041a184d6b9c6d927c83 CI 1634944096 +1100 fetch origin: storing head +d0d3bfe09c1a5a9631f3041a184d6b9c6d927c83 aea6b2960cc3e7a2453ce3490ca09d090d7ce223 CI 1634944097 +1100 update by push diff --git a/test/integration/pushFollowTags/expected/.git_keep/objects/0e/6cf0a6b79e8d44e186d812a1f74b43d64fac52 b/test/integration/pushFollowTags/expected/.git_keep/objects/0e/6cf0a6b79e8d44e186d812a1f74b43d64fac52 new file mode 100644 index 0000000000000000000000000000000000000000..7f2ebf4eeb6ad6875bcc2a2b91ca3345ee06b45e GIT binary patch literal 52 zcmb~ZE#08nZNMgRZ+ literal 0 HcmV?d00001 diff --git a/test/integration/pushFollowTags/expected/.git_keep/objects/2b/173c861df433fa43ffad13f80c8b312c5c8bce b/test/integration/pushFollowTags/expected/.git_keep/objects/2b/173c861df433fa43ffad13f80c8b312c5c8bce new file mode 100644 index 0000000000000000000000000000000000000000..0a734f98100d24e67455a3cfa8497adaccc7a422 GIT binary patch literal 103 zcmV-t0GR)H0V^p=O;s>7Fl8__FfcPQQOK=K%gjkNWLUcA@n6-{8($(qqj>V2E(CbB zbYDeLV#FZ9^TVh?Y2Ue*s}_Y<^|!pzo^PR!qQsctem1Z6nX+eZ_)jSuQWx;@*VuJL J8UTCqE3ZN5G4lWb literal 0 HcmV?d00001 diff --git a/test/integration/pushFollowTags/expected/.git_keep/objects/34/10e6811881ccede9ff762c875f9b99a3e6eaef b/test/integration/pushFollowTags/expected/.git_keep/objects/34/10e6811881ccede9ff762c875f9b99a3e6eaef new file mode 100644 index 0000000000000000000000000000000000000000..63ae5ead6117a19e15ee4066e8ca841ffd578728 GIT binary patch literal 126 zcmV-^0D=E_0TqnP3WG2Z0DI0??7bkHhmnO+3ZDFobzMYh8nHp@-#6aoFf)Z`u#Rqd zTvZCNavU8+6!F@z3#}LRflwG}Lc*yNb`~^A08nuUMF0Q* literal 0 HcmV?d00001 diff --git a/test/integration/pushFollowTags/expected/.git_keep/objects/a7/341a59f0ddeef969e69fb6368266d22b0f2416 b/test/integration/pushFollowTags/expected/.git_keep/objects/a7/341a59f0ddeef969e69fb6368266d22b0f2416 new file mode 100644 index 0000000000000000000000000000000000000000..96d2e71a6af75cdd27ac5d9628a27faecc40fb66 GIT binary patch literal 77 zcmV-T0J8sh0V^p=O;s>AU@$Z=Ff%bx$gNDv%tB=N-?^8o7KK;!x4hDxZ=ntVWIZ01*pecg literal 0 HcmV?d00001 diff --git a/test/integration/pushFollowTags/expected/.git_keep/objects/ae/a6b2960cc3e7a2453ce3490ca09d090d7ce223 b/test/integration/pushFollowTags/expected/.git_keep/objects/ae/a6b2960cc3e7a2453ce3490ca09d090d7ce223 new file mode 100644 index 0000000000000000000000000000000000000000..23f4eb7e8baafc64dfc145aab30a87816cefbd93 GIT binary patch literal 149 zcmV;G0BZku0gaA93c@fD06pgwxeJo*Zqo!rgr540?PeDX#+DL6e{Y}QX<(Sc$Xe^t zJY+hxUDbCp3@9l=F+wyZG~)tjDM*?TI_VFJx{Y^zHD5x(*)(JU?m0&U!$820sKhx- zEV&ybq2qUZth*m4e;ud0ez>`CU&08otwO#lD@ literal 0 HcmV?d00001 diff --git a/test/integration/pushFollowTags/expected/.git_keep/objects/f2/7af92910b10e6ddf592fae975337355579464b b/test/integration/pushFollowTags/expected/.git_keep/objects/f2/7af92910b10e6ddf592fae975337355579464b new file mode 100644 index 000000000..b2353a7c3 --- /dev/null +++ b/test/integration/pushFollowTags/expected/.git_keep/objects/f2/7af92910b10e6ddf592fae975337355579464b @@ -0,0 +1,2 @@ +xA +0@ѮsʌNJ\yL")#tyS5[˥*`e3쩋T^%{⧽ i-U{Iρѝ4;uSr3m, \ No newline at end of file diff --git a/test/integration/pushFollowTags/expected/.git_keep/refs/heads/master b/test/integration/pushFollowTags/expected/.git_keep/refs/heads/master new file mode 100644 index 000000000..04b4caa25 --- /dev/null +++ b/test/integration/pushFollowTags/expected/.git_keep/refs/heads/master @@ -0,0 +1 @@ +aea6b2960cc3e7a2453ce3490ca09d090d7ce223 diff --git a/test/integration/pushFollowTags/expected/.git_keep/refs/remotes/origin/master b/test/integration/pushFollowTags/expected/.git_keep/refs/remotes/origin/master new file mode 100644 index 000000000..04b4caa25 --- /dev/null +++ b/test/integration/pushFollowTags/expected/.git_keep/refs/remotes/origin/master @@ -0,0 +1 @@ +aea6b2960cc3e7a2453ce3490ca09d090d7ce223 diff --git a/test/integration/pushFollowTags/expected/.git_keep/refs/tags/v1.0 b/test/integration/pushFollowTags/expected/.git_keep/refs/tags/v1.0 new file mode 100644 index 000000000..9e7dd44c2 --- /dev/null +++ b/test/integration/pushFollowTags/expected/.git_keep/refs/tags/v1.0 @@ -0,0 +1 @@ +3410e6811881ccede9ff762c875f9b99a3e6eaef diff --git a/test/integration/pushFollowTags/expected/myfile1 b/test/integration/pushFollowTags/expected/myfile1 new file mode 100644 index 000000000..a5bce3fd2 --- /dev/null +++ b/test/integration/pushFollowTags/expected/myfile1 @@ -0,0 +1 @@ +test1 diff --git a/test/integration/pushFollowTags/expected/myfile2 b/test/integration/pushFollowTags/expected/myfile2 new file mode 100644 index 000000000..180cf8328 --- /dev/null +++ b/test/integration/pushFollowTags/expected/myfile2 @@ -0,0 +1 @@ +test2 diff --git a/test/integration/pushFollowTags/expected/myfile3 b/test/integration/pushFollowTags/expected/myfile3 new file mode 100644 index 000000000..df6b0d2bc --- /dev/null +++ b/test/integration/pushFollowTags/expected/myfile3 @@ -0,0 +1 @@ +test3 diff --git a/test/integration/pushFollowTags/expected_remote/HEAD b/test/integration/pushFollowTags/expected_remote/HEAD new file mode 100644 index 000000000..cb089cd89 --- /dev/null +++ b/test/integration/pushFollowTags/expected_remote/HEAD @@ -0,0 +1 @@ +ref: refs/heads/master diff --git a/test/integration/pushFollowTags/expected_remote/config b/test/integration/pushFollowTags/expected_remote/config new file mode 100644 index 000000000..a23b4ec0a --- /dev/null +++ b/test/integration/pushFollowTags/expected_remote/config @@ -0,0 +1,8 @@ +[core] + repositoryformatversion = 0 + filemode = true + bare = true + ignorecase = true + precomposeunicode = true +[remote "origin"] + url = /Users/jesseduffieldduffield/go/src/github.com/jesseduffield/lazygit/test/integration/pushFollowTags/./actual diff --git a/test/integration/pushFollowTags/expected_remote/description b/test/integration/pushFollowTags/expected_remote/description new file mode 100644 index 000000000..498b267a8 --- /dev/null +++ b/test/integration/pushFollowTags/expected_remote/description @@ -0,0 +1 @@ +Unnamed repository; edit this file 'description' to name the repository. diff --git a/test/integration/pushFollowTags/expected_remote/info/exclude b/test/integration/pushFollowTags/expected_remote/info/exclude new file mode 100644 index 000000000..8e9f2071f --- /dev/null +++ b/test/integration/pushFollowTags/expected_remote/info/exclude @@ -0,0 +1,7 @@ +# git ls-files --others --exclude-from=.git/info/exclude +# Lines that start with '#' are comments. +# For a project mostly in C, the following would be a good set of +# exclude patterns (uncomment them if you want to use them): +# *.[oa] +# *~ +.DS_Store diff --git a/test/integration/pushFollowTags/expected_remote/objects/0e/6cf0a6b79e8d44e186d812a1f74b43d64fac52 b/test/integration/pushFollowTags/expected_remote/objects/0e/6cf0a6b79e8d44e186d812a1f74b43d64fac52 new file mode 100644 index 0000000000000000000000000000000000000000..7f2ebf4eeb6ad6875bcc2a2b91ca3345ee06b45e GIT binary patch literal 52 zcmb~ZE#08nZNMgRZ+ literal 0 HcmV?d00001 diff --git a/test/integration/pushFollowTags/expected_remote/objects/2b/173c861df433fa43ffad13f80c8b312c5c8bce b/test/integration/pushFollowTags/expected_remote/objects/2b/173c861df433fa43ffad13f80c8b312c5c8bce new file mode 100644 index 0000000000000000000000000000000000000000..0a734f98100d24e67455a3cfa8497adaccc7a422 GIT binary patch literal 103 zcmV-t0GR)H0V^p=O;s>7Fl8__FfcPQQOK=K%gjkNWLUcA@n6-{8($(qqj>V2E(CbB zbYDeLV#FZ9^TVh?Y2Ue*s}_Y<^|!pzo^PR!qQsctem1Z6nX+eZ_)jSuQWx;@*VuJL J8UTCqE3ZN5G4lWb literal 0 HcmV?d00001 diff --git a/test/integration/pushFollowTags/expected_remote/objects/34/10e6811881ccede9ff762c875f9b99a3e6eaef b/test/integration/pushFollowTags/expected_remote/objects/34/10e6811881ccede9ff762c875f9b99a3e6eaef new file mode 100644 index 0000000000000000000000000000000000000000..63ae5ead6117a19e15ee4066e8ca841ffd578728 GIT binary patch literal 126 zcmV-^0D=E_0TqnP3WG2Z0DI0??7bkHhmnO+3ZDFobzMYh8nHp@-#6aoFf)Z`u#Rqd zTvZCNavU8+6!F@z3#}LRflwG}Lc*yNb`~^A08nuUMF0Q* literal 0 HcmV?d00001 diff --git a/test/integration/pushFollowTags/expected_remote/objects/a7/341a59f0ddeef969e69fb6368266d22b0f2416 b/test/integration/pushFollowTags/expected_remote/objects/a7/341a59f0ddeef969e69fb6368266d22b0f2416 new file mode 100644 index 0000000000000000000000000000000000000000..96d2e71a6af75cdd27ac5d9628a27faecc40fb66 GIT binary patch literal 77 zcmV-T0J8sh0V^p=O;s>AU@$Z=Ff%bx$gNDv%tB=N-?^8o7KK;!x4hDxZ=ntVWIZ01*pecg literal 0 HcmV?d00001 diff --git a/test/integration/pushFollowTags/expected_remote/objects/ae/a6b2960cc3e7a2453ce3490ca09d090d7ce223 b/test/integration/pushFollowTags/expected_remote/objects/ae/a6b2960cc3e7a2453ce3490ca09d090d7ce223 new file mode 100644 index 0000000000000000000000000000000000000000..23f4eb7e8baafc64dfc145aab30a87816cefbd93 GIT binary patch literal 149 zcmV;G0BZku0gaA93c@fD06pgwxeJo*Zqo!rgr540?PeDX#+DL6e{Y}QX<(Sc$Xe^t zJY+hxUDbCp3@9l=F+wyZG~)tjDM*?TI_VFJx{Y^zHD5x(*)(JU?m0&U!$820sKhx- zEV&ybq2qUZth*m4e;ud0ez>`CU&08otwO#lD@ literal 0 HcmV?d00001 diff --git a/test/integration/pushFollowTags/expected_remote/objects/f2/7af92910b10e6ddf592fae975337355579464b b/test/integration/pushFollowTags/expected_remote/objects/f2/7af92910b10e6ddf592fae975337355579464b new file mode 100644 index 000000000..b2353a7c3 --- /dev/null +++ b/test/integration/pushFollowTags/expected_remote/objects/f2/7af92910b10e6ddf592fae975337355579464b @@ -0,0 +1,2 @@ +xA +0@ѮsʌNJ\yL")#tyS5[˥*`e3쩋T^%{⧽ i-U{Iρѝ4;uSr3m, \ No newline at end of file diff --git a/test/integration/pushFollowTags/expected_remote/packed-refs b/test/integration/pushFollowTags/expected_remote/packed-refs new file mode 100644 index 000000000..51ac4766d --- /dev/null +++ b/test/integration/pushFollowTags/expected_remote/packed-refs @@ -0,0 +1,2 @@ +# pack-refs with: peeled fully-peeled sorted +d0d3bfe09c1a5a9631f3041a184d6b9c6d927c83 refs/heads/master diff --git a/test/integration/pushFollowTags/expected_remote/refs/heads/master b/test/integration/pushFollowTags/expected_remote/refs/heads/master new file mode 100644 index 000000000..04b4caa25 --- /dev/null +++ b/test/integration/pushFollowTags/expected_remote/refs/heads/master @@ -0,0 +1 @@ +aea6b2960cc3e7a2453ce3490ca09d090d7ce223 diff --git a/test/integration/pushFollowTags/expected_remote/refs/tags/v1.0 b/test/integration/pushFollowTags/expected_remote/refs/tags/v1.0 new file mode 100644 index 000000000..9e7dd44c2 --- /dev/null +++ b/test/integration/pushFollowTags/expected_remote/refs/tags/v1.0 @@ -0,0 +1 @@ +3410e6811881ccede9ff762c875f9b99a3e6eaef diff --git a/test/integration/pushFollowTags/recording.json b/test/integration/pushFollowTags/recording.json new file mode 100644 index 000000000..43fd3fa5b --- /dev/null +++ b/test/integration/pushFollowTags/recording.json @@ -0,0 +1 @@ +{"KeyEvents":[{"Timestamp":682,"Mod":0,"Key":256,"Ch":80},{"Timestamp":1641,"Mod":0,"Key":256,"Ch":113}],"ResizeEvents":[{"Timestamp":0,"Width":272,"Height":74}]} \ No newline at end of file diff --git a/test/integration/pushFollowTags/setup.sh b/test/integration/pushFollowTags/setup.sh new file mode 100644 index 000000000..2da0cbf18 --- /dev/null +++ b/test/integration/pushFollowTags/setup.sh @@ -0,0 +1,32 @@ +#!/bin/sh + +set -e + +cd $1 + +git init + +git config user.email "CI@example.com" +git config user.name "CI" + +echo test1 > myfile1 +git add . +git commit -am "myfile1" +echo test2 > myfile2 +git add . +git commit -am "myfile2" + +cd .. +git clone --bare ./actual actual_remote + +cd actual + +echo test3 > myfile3 +git add . +git commit -am "myfile3" + +git remote add origin ../actual_remote +git fetch origin +git branch --set-upstream-to=origin/master master +git config push.followTags true +git tag -a v1.0 -m "my version 1.0" diff --git a/test/integration/pushFollowTags/test.json b/test/integration/pushFollowTags/test.json new file mode 100644 index 000000000..1c8b13c9f --- /dev/null +++ b/test/integration/pushFollowTags/test.json @@ -0,0 +1 @@ +{ "description": "push changes to the remote, when --follow-tags is configured", "speed": 10 } diff --git a/test/integration/pushNoFollowTags/expected/.git_keep/COMMIT_EDITMSG b/test/integration/pushNoFollowTags/expected/.git_keep/COMMIT_EDITMSG new file mode 100644 index 000000000..c23aa0355 --- /dev/null +++ b/test/integration/pushNoFollowTags/expected/.git_keep/COMMIT_EDITMSG @@ -0,0 +1 @@ +myfile3 diff --git a/test/integration/pushNoFollowTags/expected/.git_keep/FETCH_HEAD b/test/integration/pushNoFollowTags/expected/.git_keep/FETCH_HEAD new file mode 100644 index 000000000..ce7bd7286 --- /dev/null +++ b/test/integration/pushNoFollowTags/expected/.git_keep/FETCH_HEAD @@ -0,0 +1 @@ +8f99b05bf3462e1a797335475bff5fabe3ae9ec5 branch 'master' of ../actual_remote diff --git a/test/integration/pushNoFollowTags/expected/.git_keep/HEAD b/test/integration/pushNoFollowTags/expected/.git_keep/HEAD new file mode 100644 index 000000000..cb089cd89 --- /dev/null +++ b/test/integration/pushNoFollowTags/expected/.git_keep/HEAD @@ -0,0 +1 @@ +ref: refs/heads/master diff --git a/test/integration/pushNoFollowTags/expected/.git_keep/config b/test/integration/pushNoFollowTags/expected/.git_keep/config new file mode 100644 index 000000000..821803a3e --- /dev/null +++ b/test/integration/pushNoFollowTags/expected/.git_keep/config @@ -0,0 +1,16 @@ +[core] + repositoryformatversion = 0 + filemode = true + bare = false + logallrefupdates = true + ignorecase = true + precomposeunicode = true +[user] + email = CI@example.com + name = CI +[remote "origin"] + url = ../actual_remote + fetch = +refs/heads/*:refs/remotes/origin/* +[branch "master"] + remote = origin + merge = refs/heads/master diff --git a/test/integration/pushNoFollowTags/expected/.git_keep/description b/test/integration/pushNoFollowTags/expected/.git_keep/description new file mode 100644 index 000000000..498b267a8 --- /dev/null +++ b/test/integration/pushNoFollowTags/expected/.git_keep/description @@ -0,0 +1 @@ +Unnamed repository; edit this file 'description' to name the repository. diff --git a/test/integration/pushNoFollowTags/expected/.git_keep/index b/test/integration/pushNoFollowTags/expected/.git_keep/index new file mode 100644 index 0000000000000000000000000000000000000000..818799f5dc9c4e3d730fbcb4956287c019883d07 GIT binary patch literal 281 zcmZ?q402{*U|<4b=EP!`BC{uUc`%xhfq|7V@}emNL*o(#2F9;IH6lRFwsg zzC?sZ@#H&Q2=Hp@zRJL!TbY)blWGW50Mc*4RTB)Oq2~CYnB=N-?^8o7KK;! zx4hDxZ=nt|#|UbU)iICvAag)8)SNl!=G@Qb)jm`9><#}Zg+uBBUj7=pj!47IF$S6w z66ER%q$C-P6%4qv#ckSTzZm~={=ZiE2T!-5PE7YXS@+k9(Vx?uv}We*iPFj5q%7kk F3;-WaSA_ro literal 0 HcmV?d00001 diff --git a/test/integration/pushNoFollowTags/expected/.git_keep/info/exclude b/test/integration/pushNoFollowTags/expected/.git_keep/info/exclude new file mode 100644 index 000000000..8e9f2071f --- /dev/null +++ b/test/integration/pushNoFollowTags/expected/.git_keep/info/exclude @@ -0,0 +1,7 @@ +# git ls-files --others --exclude-from=.git/info/exclude +# Lines that start with '#' are comments. +# For a project mostly in C, the following would be a good set of +# exclude patterns (uncomment them if you want to use them): +# *.[oa] +# *~ +.DS_Store diff --git a/test/integration/pushNoFollowTags/expected/.git_keep/logs/HEAD b/test/integration/pushNoFollowTags/expected/.git_keep/logs/HEAD new file mode 100644 index 000000000..429f8a7fc --- /dev/null +++ b/test/integration/pushNoFollowTags/expected/.git_keep/logs/HEAD @@ -0,0 +1,3 @@ +0000000000000000000000000000000000000000 fb20b9e96648c61699f9faf3a4383340fefd5f91 CI 1634944114 +1100 commit (initial): myfile1 +fb20b9e96648c61699f9faf3a4383340fefd5f91 8f99b05bf3462e1a797335475bff5fabe3ae9ec5 CI 1634944114 +1100 commit: myfile2 +8f99b05bf3462e1a797335475bff5fabe3ae9ec5 03009ca2af4be2a9bb49206974ce9c97eaa2da23 CI 1634944114 +1100 commit: myfile3 diff --git a/test/integration/pushNoFollowTags/expected/.git_keep/logs/refs/heads/master b/test/integration/pushNoFollowTags/expected/.git_keep/logs/refs/heads/master new file mode 100644 index 000000000..429f8a7fc --- /dev/null +++ b/test/integration/pushNoFollowTags/expected/.git_keep/logs/refs/heads/master @@ -0,0 +1,3 @@ +0000000000000000000000000000000000000000 fb20b9e96648c61699f9faf3a4383340fefd5f91 CI 1634944114 +1100 commit (initial): myfile1 +fb20b9e96648c61699f9faf3a4383340fefd5f91 8f99b05bf3462e1a797335475bff5fabe3ae9ec5 CI 1634944114 +1100 commit: myfile2 +8f99b05bf3462e1a797335475bff5fabe3ae9ec5 03009ca2af4be2a9bb49206974ce9c97eaa2da23 CI 1634944114 +1100 commit: myfile3 diff --git a/test/integration/pushNoFollowTags/expected/.git_keep/logs/refs/remotes/origin/master b/test/integration/pushNoFollowTags/expected/.git_keep/logs/refs/remotes/origin/master new file mode 100644 index 000000000..42331700f --- /dev/null +++ b/test/integration/pushNoFollowTags/expected/.git_keep/logs/refs/remotes/origin/master @@ -0,0 +1,2 @@ +0000000000000000000000000000000000000000 8f99b05bf3462e1a797335475bff5fabe3ae9ec5 CI 1634944115 +1100 fetch origin: storing head +8f99b05bf3462e1a797335475bff5fabe3ae9ec5 03009ca2af4be2a9bb49206974ce9c97eaa2da23 CI 1634944115 +1100 update by push diff --git a/test/integration/pushNoFollowTags/expected/.git_keep/objects/03/009ca2af4be2a9bb49206974ce9c97eaa2da23 b/test/integration/pushNoFollowTags/expected/.git_keep/objects/03/009ca2af4be2a9bb49206974ce9c97eaa2da23 new file mode 100644 index 0000000000000000000000000000000000000000..4a4d1b682f605065fe6889881b0ebaa270e786cc GIT binary patch literal 148 zcmV;F0Biqv0gaA93c@fD06pgwxeJo*Zkhx{gr540O}dK(V@rvkzc)|tG%(Cz%2w;z zEF?O$L&Odl0+u+!qJ*eSsLBhVMpt4+7>e&KVs<{{)oj$1vh!Jy#zBBX3W%OUH|mwM zAWM?s4ZquCJM1*u>onix!*zekrEK+PVMIzq0A$Yq&Y5oeRFgk*Q@^@C1~ZE#08nZNMgRZ+ literal 0 HcmV?d00001 diff --git a/test/integration/pushNoFollowTags/expected/.git_keep/objects/2b/173c861df433fa43ffad13f80c8b312c5c8bce b/test/integration/pushNoFollowTags/expected/.git_keep/objects/2b/173c861df433fa43ffad13f80c8b312c5c8bce new file mode 100644 index 0000000000000000000000000000000000000000..0a734f98100d24e67455a3cfa8497adaccc7a422 GIT binary patch literal 103 zcmV-t0GR)H0V^p=O;s>7Fl8__FfcPQQOK=K%gjkNWLUcA@n6-{8($(qqj>V2E(CbB zbYDeLV#FZ9^TVh?Y2Ue*s}_Y<^|!pzo^PR!qQsctem1Z6nX+eZ_)jSuQWx;@*VuJL J8UTCqE3ZN5G4lWb literal 0 HcmV?d00001 diff --git a/test/integration/pushNoFollowTags/expected/.git_keep/objects/8f/99b05bf3462e1a797335475bff5fabe3ae9ec5 b/test/integration/pushNoFollowTags/expected/.git_keep/objects/8f/99b05bf3462e1a797335475bff5fabe3ae9ec5 new file mode 100644 index 000000000..1e525bf69 --- /dev/null +++ b/test/integration/pushNoFollowTags/expected/.git_keep/objects/8f/99b05bf3462e1a797335475bff5fabe3ae9ec5 @@ -0,0 +1,3 @@ +xA +0@Q9$ӱ"BW=F`D#şZ(tj*k$L/EՄEY,s>0@nKX> +3#X(17ҙK\wF C?n^9!wG=]ڼhp?:: \ No newline at end of file diff --git a/test/integration/pushNoFollowTags/expected/.git_keep/objects/a5/bce3fd2565d8f458555a0c6f42d0504a848bd5 b/test/integration/pushNoFollowTags/expected/.git_keep/objects/a5/bce3fd2565d8f458555a0c6f42d0504a848bd5 new file mode 100644 index 0000000000000000000000000000000000000000..285df3e5fbab12262e28d85e78af8a31cd0024c1 GIT binary patch literal 21 ccmb`~^A08nuUMF0Q* literal 0 HcmV?d00001 diff --git a/test/integration/pushNoFollowTags/expected/.git_keep/objects/a7/341a59f0ddeef969e69fb6368266d22b0f2416 b/test/integration/pushNoFollowTags/expected/.git_keep/objects/a7/341a59f0ddeef969e69fb6368266d22b0f2416 new file mode 100644 index 0000000000000000000000000000000000000000..96d2e71a6af75cdd27ac5d9628a27faecc40fb66 GIT binary patch literal 77 zcmV-T0J8sh0V^p=O;s>AU@$Z=Ff%bx$gNDv%tB=N-?^8o7KK;!x4hDxZ=ntVWIZ01*pecg literal 0 HcmV?d00001 diff --git a/test/integration/pushNoFollowTags/expected/.git_keep/objects/df/6b0d2bcc76e6ec0fca20c227104a4f28bac41b b/test/integration/pushNoFollowTags/expected/.git_keep/objects/df/6b0d2bcc76e6ec0fca20c227104a4f28bac41b new file mode 100644 index 0000000000000000000000000000000000000000..9b771fc2f6f41f91b00976b4ff3f8f9935f7931e GIT binary patch literal 21 ccmb>`CU&08otwO#lD@ literal 0 HcmV?d00001 diff --git a/test/integration/pushNoFollowTags/expected/.git_keep/objects/e1/9bd88e6b3a0d7e4ffc1de39b34d5a312fb9b77 b/test/integration/pushNoFollowTags/expected/.git_keep/objects/e1/9bd88e6b3a0d7e4ffc1de39b34d5a312fb9b77 new file mode 100644 index 0000000000000000000000000000000000000000..33f59a1d3fa667221717b6bd7654acb41733b08f GIT binary patch literal 127 zcmV-_0D%8^0Tqlv3c@fD06pgwdl$;?Cbley2tD-~o4A&WF{OrLe{Xx6!^~72fmlu@ zzARNhk0?o5pCKBn#2AFJl`bTcB%P`9L)p8!%?7FDJXKfs$4U(zFxmqB0M~xF+fVcS hwr00(K&=lF0?`G|M2ODi4OUyeQ~AKr{sHR=C$FM7I%EI< literal 0 HcmV?d00001 diff --git a/test/integration/pushNoFollowTags/expected/.git_keep/objects/fb/20b9e96648c61699f9faf3a4383340fefd5f91 b/test/integration/pushNoFollowTags/expected/.git_keep/objects/fb/20b9e96648c61699f9faf3a4383340fefd5f91 new file mode 100644 index 000000000..8160387e5 --- /dev/null +++ b/test/integration/pushNoFollowTags/expected/.git_keep/objects/fb/20b9e96648c61699f9faf3a4383340fefd5f91 @@ -0,0 +1,3 @@ +xA +0Fa9ߎDz4`CD#}|R5[vU*(0j̊ 9(/gӵsݞui4?%U`:޻rg߲n +0, \ No newline at end of file diff --git a/test/integration/pushNoFollowTags/expected/.git_keep/refs/heads/master b/test/integration/pushNoFollowTags/expected/.git_keep/refs/heads/master new file mode 100644 index 000000000..c5beb70f7 --- /dev/null +++ b/test/integration/pushNoFollowTags/expected/.git_keep/refs/heads/master @@ -0,0 +1 @@ +03009ca2af4be2a9bb49206974ce9c97eaa2da23 diff --git a/test/integration/pushNoFollowTags/expected/.git_keep/refs/remotes/origin/master b/test/integration/pushNoFollowTags/expected/.git_keep/refs/remotes/origin/master new file mode 100644 index 000000000..c5beb70f7 --- /dev/null +++ b/test/integration/pushNoFollowTags/expected/.git_keep/refs/remotes/origin/master @@ -0,0 +1 @@ +03009ca2af4be2a9bb49206974ce9c97eaa2da23 diff --git a/test/integration/pushNoFollowTags/expected/.git_keep/refs/tags/v1.0 b/test/integration/pushNoFollowTags/expected/.git_keep/refs/tags/v1.0 new file mode 100644 index 000000000..b4c9b638f --- /dev/null +++ b/test/integration/pushNoFollowTags/expected/.git_keep/refs/tags/v1.0 @@ -0,0 +1 @@ +e19bd88e6b3a0d7e4ffc1de39b34d5a312fb9b77 diff --git a/test/integration/pushNoFollowTags/expected/myfile1 b/test/integration/pushNoFollowTags/expected/myfile1 new file mode 100644 index 000000000..a5bce3fd2 --- /dev/null +++ b/test/integration/pushNoFollowTags/expected/myfile1 @@ -0,0 +1 @@ +test1 diff --git a/test/integration/pushNoFollowTags/expected/myfile2 b/test/integration/pushNoFollowTags/expected/myfile2 new file mode 100644 index 000000000..180cf8328 --- /dev/null +++ b/test/integration/pushNoFollowTags/expected/myfile2 @@ -0,0 +1 @@ +test2 diff --git a/test/integration/pushNoFollowTags/expected/myfile3 b/test/integration/pushNoFollowTags/expected/myfile3 new file mode 100644 index 000000000..df6b0d2bc --- /dev/null +++ b/test/integration/pushNoFollowTags/expected/myfile3 @@ -0,0 +1 @@ +test3 diff --git a/test/integration/pushNoFollowTags/expected_remote/HEAD b/test/integration/pushNoFollowTags/expected_remote/HEAD new file mode 100644 index 000000000..cb089cd89 --- /dev/null +++ b/test/integration/pushNoFollowTags/expected_remote/HEAD @@ -0,0 +1 @@ +ref: refs/heads/master diff --git a/test/integration/pushNoFollowTags/expected_remote/config b/test/integration/pushNoFollowTags/expected_remote/config new file mode 100644 index 000000000..01095ff3a --- /dev/null +++ b/test/integration/pushNoFollowTags/expected_remote/config @@ -0,0 +1,8 @@ +[core] + repositoryformatversion = 0 + filemode = true + bare = true + ignorecase = true + precomposeunicode = true +[remote "origin"] + url = /Users/jesseduffieldduffield/go/src/github.com/jesseduffield/lazygit/test/integration/pushNoFollowTags/./actual diff --git a/test/integration/pushNoFollowTags/expected_remote/description b/test/integration/pushNoFollowTags/expected_remote/description new file mode 100644 index 000000000..498b267a8 --- /dev/null +++ b/test/integration/pushNoFollowTags/expected_remote/description @@ -0,0 +1 @@ +Unnamed repository; edit this file 'description' to name the repository. diff --git a/test/integration/pushNoFollowTags/expected_remote/info/exclude b/test/integration/pushNoFollowTags/expected_remote/info/exclude new file mode 100644 index 000000000..8e9f2071f --- /dev/null +++ b/test/integration/pushNoFollowTags/expected_remote/info/exclude @@ -0,0 +1,7 @@ +# git ls-files --others --exclude-from=.git/info/exclude +# Lines that start with '#' are comments. +# For a project mostly in C, the following would be a good set of +# exclude patterns (uncomment them if you want to use them): +# *.[oa] +# *~ +.DS_Store diff --git a/test/integration/pushNoFollowTags/expected_remote/objects/03/009ca2af4be2a9bb49206974ce9c97eaa2da23 b/test/integration/pushNoFollowTags/expected_remote/objects/03/009ca2af4be2a9bb49206974ce9c97eaa2da23 new file mode 100644 index 0000000000000000000000000000000000000000..4a4d1b682f605065fe6889881b0ebaa270e786cc GIT binary patch literal 148 zcmV;F0Biqv0gaA93c@fD06pgwxeJo*Zkhx{gr540O}dK(V@rvkzc)|tG%(Cz%2w;z zEF?O$L&Odl0+u+!qJ*eSsLBhVMpt4+7>e&KVs<{{)oj$1vh!Jy#zBBX3W%OUH|mwM zAWM?s4ZquCJM1*u>onix!*zekrEK+PVMIzq0A$Yq&Y5oeRFgk*Q@^@C1~ZE#08nZNMgRZ+ literal 0 HcmV?d00001 diff --git a/test/integration/pushNoFollowTags/expected_remote/objects/2b/173c861df433fa43ffad13f80c8b312c5c8bce b/test/integration/pushNoFollowTags/expected_remote/objects/2b/173c861df433fa43ffad13f80c8b312c5c8bce new file mode 100644 index 0000000000000000000000000000000000000000..0a734f98100d24e67455a3cfa8497adaccc7a422 GIT binary patch literal 103 zcmV-t0GR)H0V^p=O;s>7Fl8__FfcPQQOK=K%gjkNWLUcA@n6-{8($(qqj>V2E(CbB zbYDeLV#FZ9^TVh?Y2Ue*s}_Y<^|!pzo^PR!qQsctem1Z6nX+eZ_)jSuQWx;@*VuJL J8UTCqE3ZN5G4lWb literal 0 HcmV?d00001 diff --git a/test/integration/pushNoFollowTags/expected_remote/objects/8f/99b05bf3462e1a797335475bff5fabe3ae9ec5 b/test/integration/pushNoFollowTags/expected_remote/objects/8f/99b05bf3462e1a797335475bff5fabe3ae9ec5 new file mode 100644 index 000000000..1e525bf69 --- /dev/null +++ b/test/integration/pushNoFollowTags/expected_remote/objects/8f/99b05bf3462e1a797335475bff5fabe3ae9ec5 @@ -0,0 +1,3 @@ +xA +0@Q9$ӱ"BW=F`D#şZ(tj*k$L/EՄEY,s>0@nKX> +3#X(17ҙK\wF C?n^9!wG=]ڼhp?:: \ No newline at end of file diff --git a/test/integration/pushNoFollowTags/expected_remote/objects/a5/bce3fd2565d8f458555a0c6f42d0504a848bd5 b/test/integration/pushNoFollowTags/expected_remote/objects/a5/bce3fd2565d8f458555a0c6f42d0504a848bd5 new file mode 100644 index 0000000000000000000000000000000000000000..285df3e5fbab12262e28d85e78af8a31cd0024c1 GIT binary patch literal 21 ccmb`~^A08nuUMF0Q* literal 0 HcmV?d00001 diff --git a/test/integration/pushNoFollowTags/expected_remote/objects/a7/341a59f0ddeef969e69fb6368266d22b0f2416 b/test/integration/pushNoFollowTags/expected_remote/objects/a7/341a59f0ddeef969e69fb6368266d22b0f2416 new file mode 100644 index 0000000000000000000000000000000000000000..96d2e71a6af75cdd27ac5d9628a27faecc40fb66 GIT binary patch literal 77 zcmV-T0J8sh0V^p=O;s>AU@$Z=Ff%bx$gNDv%tB=N-?^8o7KK;!x4hDxZ=ntVWIZ01*pecg literal 0 HcmV?d00001 diff --git a/test/integration/pushNoFollowTags/expected_remote/objects/df/6b0d2bcc76e6ec0fca20c227104a4f28bac41b b/test/integration/pushNoFollowTags/expected_remote/objects/df/6b0d2bcc76e6ec0fca20c227104a4f28bac41b new file mode 100644 index 0000000000000000000000000000000000000000..9b771fc2f6f41f91b00976b4ff3f8f9935f7931e GIT binary patch literal 21 ccmb>`CU&08otwO#lD@ literal 0 HcmV?d00001 diff --git a/test/integration/pushNoFollowTags/expected_remote/objects/fb/20b9e96648c61699f9faf3a4383340fefd5f91 b/test/integration/pushNoFollowTags/expected_remote/objects/fb/20b9e96648c61699f9faf3a4383340fefd5f91 new file mode 100644 index 000000000..8160387e5 --- /dev/null +++ b/test/integration/pushNoFollowTags/expected_remote/objects/fb/20b9e96648c61699f9faf3a4383340fefd5f91 @@ -0,0 +1,3 @@ +xA +0Fa9ߎDz4`CD#}|R5[vU*(0j̊ 9(/gӵsݞui4?%U`:޻rg߲n +0, \ No newline at end of file diff --git a/test/integration/pushNoFollowTags/expected_remote/packed-refs b/test/integration/pushNoFollowTags/expected_remote/packed-refs new file mode 100644 index 000000000..cb3f85f2e --- /dev/null +++ b/test/integration/pushNoFollowTags/expected_remote/packed-refs @@ -0,0 +1,2 @@ +# pack-refs with: peeled fully-peeled sorted +8f99b05bf3462e1a797335475bff5fabe3ae9ec5 refs/heads/master diff --git a/test/integration/pushNoFollowTags/expected_remote/refs/heads/master b/test/integration/pushNoFollowTags/expected_remote/refs/heads/master new file mode 100644 index 000000000..c5beb70f7 --- /dev/null +++ b/test/integration/pushNoFollowTags/expected_remote/refs/heads/master @@ -0,0 +1 @@ +03009ca2af4be2a9bb49206974ce9c97eaa2da23 diff --git a/test/integration/pushNoFollowTags/recording.json b/test/integration/pushNoFollowTags/recording.json new file mode 100644 index 000000000..428f83f07 --- /dev/null +++ b/test/integration/pushNoFollowTags/recording.json @@ -0,0 +1 @@ +{"KeyEvents":[{"Timestamp":636,"Mod":0,"Key":256,"Ch":80},{"Timestamp":1563,"Mod":0,"Key":256,"Ch":113}],"ResizeEvents":[{"Timestamp":0,"Width":272,"Height":74}]} \ No newline at end of file diff --git a/test/integration/pushNoFollowTags/setup.sh b/test/integration/pushNoFollowTags/setup.sh new file mode 100644 index 000000000..304dcd9e9 --- /dev/null +++ b/test/integration/pushNoFollowTags/setup.sh @@ -0,0 +1,31 @@ +#!/bin/sh + +set -e + +cd $1 + +git init + +git config user.email "CI@example.com" +git config user.name "CI" + +echo test1 > myfile1 +git add . +git commit -am "myfile1" +echo test2 > myfile2 +git add . +git commit -am "myfile2" + +cd .. +git clone --bare ./actual actual_remote + +cd actual + +echo test3 > myfile3 +git add . +git commit -am "myfile3" + +git remote add origin ../actual_remote +git fetch origin +git branch --set-upstream-to=origin/master master +git tag -a v1.0 -m "my version 1.0" diff --git a/test/integration/pushNoFollowTags/test.json b/test/integration/pushNoFollowTags/test.json new file mode 100644 index 000000000..65f6b3409 --- /dev/null +++ b/test/integration/pushNoFollowTags/test.json @@ -0,0 +1 @@ +{ "description": "push changes to the remote, when --follow-tags is not configured", "speed": 10 } diff --git a/test/integration/pushTag/expected/.git_keep/COMMIT_EDITMSG b/test/integration/pushTag/expected/.git_keep/COMMIT_EDITMSG new file mode 100644 index 000000000..f4b7a0e26 --- /dev/null +++ b/test/integration/pushTag/expected/.git_keep/COMMIT_EDITMSG @@ -0,0 +1 @@ +myfile2 diff --git a/test/integration/pushTag/expected/.git_keep/FETCH_HEAD b/test/integration/pushTag/expected/.git_keep/FETCH_HEAD new file mode 100644 index 000000000..fb3f085ba --- /dev/null +++ b/test/integration/pushTag/expected/.git_keep/FETCH_HEAD @@ -0,0 +1 @@ +9639a47a7955a338919b090835305898ea516c66 branch 'master' of ../actual_remote diff --git a/test/integration/pushTag/expected/.git_keep/HEAD b/test/integration/pushTag/expected/.git_keep/HEAD new file mode 100644 index 000000000..cb089cd89 --- /dev/null +++ b/test/integration/pushTag/expected/.git_keep/HEAD @@ -0,0 +1 @@ +ref: refs/heads/master diff --git a/test/integration/pushTag/expected/.git_keep/config b/test/integration/pushTag/expected/.git_keep/config new file mode 100644 index 000000000..821803a3e --- /dev/null +++ b/test/integration/pushTag/expected/.git_keep/config @@ -0,0 +1,16 @@ +[core] + repositoryformatversion = 0 + filemode = true + bare = false + logallrefupdates = true + ignorecase = true + precomposeunicode = true +[user] + email = CI@example.com + name = CI +[remote "origin"] + url = ../actual_remote + fetch = +refs/heads/*:refs/remotes/origin/* +[branch "master"] + remote = origin + merge = refs/heads/master diff --git a/test/integration/pushTag/expected/.git_keep/description b/test/integration/pushTag/expected/.git_keep/description new file mode 100644 index 000000000..498b267a8 --- /dev/null +++ b/test/integration/pushTag/expected/.git_keep/description @@ -0,0 +1 @@ +Unnamed repository; edit this file 'description' to name the repository. diff --git a/test/integration/pushTag/expected/.git_keep/index b/test/integration/pushTag/expected/.git_keep/index new file mode 100644 index 0000000000000000000000000000000000000000..b9d835e982d1017df694dc05773f371462bf3538 GIT binary patch literal 209 zcmZ?q402{*U|<5_#A4T-=In>~U^F8G11n?X^&JchjY}997{3D5hyXF$(mjv=s;1uf z5)m53lkapPz^kSEDg%3NWm;xVsv%GTSpWYp85j*U=RCSO5+cvXMP zEA9Cf>M(PRfaZh*xw--=Nd_YY1Fq#JQjs6-zWbT^Z2mU0rnF1i{3>Ec%WwZvpY;5P REc3(M9(LAPle=Gz0|4|uM#BIA literal 0 HcmV?d00001 diff --git a/test/integration/pushTag/expected/.git_keep/info/exclude b/test/integration/pushTag/expected/.git_keep/info/exclude new file mode 100644 index 000000000..8e9f2071f --- /dev/null +++ b/test/integration/pushTag/expected/.git_keep/info/exclude @@ -0,0 +1,7 @@ +# git ls-files --others --exclude-from=.git/info/exclude +# Lines that start with '#' are comments. +# For a project mostly in C, the following would be a good set of +# exclude patterns (uncomment them if you want to use them): +# *.[oa] +# *~ +.DS_Store diff --git a/test/integration/pushTag/expected/.git_keep/logs/HEAD b/test/integration/pushTag/expected/.git_keep/logs/HEAD new file mode 100644 index 000000000..406014feb --- /dev/null +++ b/test/integration/pushTag/expected/.git_keep/logs/HEAD @@ -0,0 +1,2 @@ +0000000000000000000000000000000000000000 905961711d3f0898c003c7e4da636a4c683f7934 CI 1634944441 +1100 commit (initial): myfile1 +905961711d3f0898c003c7e4da636a4c683f7934 9639a47a7955a338919b090835305898ea516c66 CI 1634944441 +1100 commit: myfile2 diff --git a/test/integration/pushTag/expected/.git_keep/logs/refs/heads/master b/test/integration/pushTag/expected/.git_keep/logs/refs/heads/master new file mode 100644 index 000000000..406014feb --- /dev/null +++ b/test/integration/pushTag/expected/.git_keep/logs/refs/heads/master @@ -0,0 +1,2 @@ +0000000000000000000000000000000000000000 905961711d3f0898c003c7e4da636a4c683f7934 CI 1634944441 +1100 commit (initial): myfile1 +905961711d3f0898c003c7e4da636a4c683f7934 9639a47a7955a338919b090835305898ea516c66 CI 1634944441 +1100 commit: myfile2 diff --git a/test/integration/pushTag/expected/.git_keep/logs/refs/remotes/origin/master b/test/integration/pushTag/expected/.git_keep/logs/refs/remotes/origin/master new file mode 100644 index 000000000..a2798f571 --- /dev/null +++ b/test/integration/pushTag/expected/.git_keep/logs/refs/remotes/origin/master @@ -0,0 +1 @@ +0000000000000000000000000000000000000000 9639a47a7955a338919b090835305898ea516c66 CI 1634944442 +1100 fetch origin: storing head diff --git a/test/integration/pushTag/expected/.git_keep/objects/0e/6cf0a6b79e8d44e186d812a1f74b43d64fac52 b/test/integration/pushTag/expected/.git_keep/objects/0e/6cf0a6b79e8d44e186d812a1f74b43d64fac52 new file mode 100644 index 0000000000000000000000000000000000000000..7f2ebf4eeb6ad6875bcc2a2b91ca3345ee06b45e GIT binary patch literal 52 zcmb~ZE#08nZNMgRZ+ literal 0 HcmV?d00001 diff --git a/test/integration/pushTag/expected/.git_keep/objects/90/5961711d3f0898c003c7e4da636a4c683f7934 b/test/integration/pushTag/expected/.git_keep/objects/90/5961711d3f0898c003c7e4da636a4c683f7934 new file mode 100644 index 0000000000000000000000000000000000000000..f060761fd50dd1c6c424a86aac673ddff208770e GIT binary patch literal 119 zcmV--0Eqv10ga783WG2Z0DI0W_FgDi-L4Tz5j^>fHQ7+XB}Gzbe{Y`9ISvC8i`iBI zi7)j~1+N^l7hZ=^Ln2ZPoC0=&d7zd0#FQo8J13v|DhJF9JmzK6uh@InTP*ejcg?m*)jxA*zr5{=?gTN7EXizoG<^U7 literal 0 HcmV?d00001 diff --git a/test/integration/pushTag/expected/.git_keep/objects/96/39a47a7955a338919b090835305898ea516c66 b/test/integration/pushTag/expected/.git_keep/objects/96/39a47a7955a338919b090835305898ea516c66 new file mode 100644 index 0000000000000000000000000000000000000000..24378078363eed8cba9226652b5bead751e10083 GIT binary patch literal 149 zcmV;G0BZku0gaA93c@fDMP26<*$Xn0OeY->5xVLz(qw`KV@rvkw>L-dFCXv0Pg|{P zvnX_GhpLUi6UIRbpB!du)fDW_z9HyMAKbpL$7Ky;)>WLVak@hybS3eyZu8x~bo?KGm5YSywqg DRUAdc literal 0 HcmV?d00001 diff --git a/test/integration/pushTag/expected/.git_keep/objects/a5/bce3fd2565d8f458555a0c6f42d0504a848bd5 b/test/integration/pushTag/expected/.git_keep/objects/a5/bce3fd2565d8f458555a0c6f42d0504a848bd5 new file mode 100644 index 0000000000000000000000000000000000000000..285df3e5fbab12262e28d85e78af8a31cd0024c1 GIT binary patch literal 21 ccmb`~^A08nuUMF0Q* literal 0 HcmV?d00001 diff --git a/test/integration/pushTag/expected/.git_keep/objects/a7/341a59f0ddeef969e69fb6368266d22b0f2416 b/test/integration/pushTag/expected/.git_keep/objects/a7/341a59f0ddeef969e69fb6368266d22b0f2416 new file mode 100644 index 0000000000000000000000000000000000000000..96d2e71a6af75cdd27ac5d9628a27faecc40fb66 GIT binary patch literal 77 zcmV-T0J8sh0V^p=O;s>AU@$Z=Ff%bx$gNDv%tB=N-?^8o7KK;!x4hDxZ=ntVWIZ01*pecg literal 0 HcmV?d00001 diff --git a/test/integration/pushTag/expected/.git_keep/refs/heads/master b/test/integration/pushTag/expected/.git_keep/refs/heads/master new file mode 100644 index 000000000..442efe33e --- /dev/null +++ b/test/integration/pushTag/expected/.git_keep/refs/heads/master @@ -0,0 +1 @@ +9639a47a7955a338919b090835305898ea516c66 diff --git a/test/integration/pushTag/expected/.git_keep/refs/remotes/origin/master b/test/integration/pushTag/expected/.git_keep/refs/remotes/origin/master new file mode 100644 index 000000000..442efe33e --- /dev/null +++ b/test/integration/pushTag/expected/.git_keep/refs/remotes/origin/master @@ -0,0 +1 @@ +9639a47a7955a338919b090835305898ea516c66 diff --git a/test/integration/pushTag/expected/.git_keep/refs/tags/v1.0 b/test/integration/pushTag/expected/.git_keep/refs/tags/v1.0 new file mode 100644 index 000000000..442efe33e --- /dev/null +++ b/test/integration/pushTag/expected/.git_keep/refs/tags/v1.0 @@ -0,0 +1 @@ +9639a47a7955a338919b090835305898ea516c66 diff --git a/test/integration/pushTag/expected/myfile1 b/test/integration/pushTag/expected/myfile1 new file mode 100644 index 000000000..a5bce3fd2 --- /dev/null +++ b/test/integration/pushTag/expected/myfile1 @@ -0,0 +1 @@ +test1 diff --git a/test/integration/pushTag/expected/myfile2 b/test/integration/pushTag/expected/myfile2 new file mode 100644 index 000000000..180cf8328 --- /dev/null +++ b/test/integration/pushTag/expected/myfile2 @@ -0,0 +1 @@ +test2 diff --git a/test/integration/pushTag/expected_remote/HEAD b/test/integration/pushTag/expected_remote/HEAD new file mode 100644 index 000000000..cb089cd89 --- /dev/null +++ b/test/integration/pushTag/expected_remote/HEAD @@ -0,0 +1 @@ +ref: refs/heads/master diff --git a/test/integration/pushTag/expected_remote/config b/test/integration/pushTag/expected_remote/config new file mode 100644 index 000000000..6b41174e6 --- /dev/null +++ b/test/integration/pushTag/expected_remote/config @@ -0,0 +1,8 @@ +[core] + repositoryformatversion = 0 + filemode = true + bare = true + ignorecase = true + precomposeunicode = true +[remote "origin"] + url = /Users/jesseduffieldduffield/go/src/github.com/jesseduffield/lazygit/test/integration/pushTag/./actual diff --git a/test/integration/pushTag/expected_remote/description b/test/integration/pushTag/expected_remote/description new file mode 100644 index 000000000..498b267a8 --- /dev/null +++ b/test/integration/pushTag/expected_remote/description @@ -0,0 +1 @@ +Unnamed repository; edit this file 'description' to name the repository. diff --git a/test/integration/pushTag/expected_remote/info/exclude b/test/integration/pushTag/expected_remote/info/exclude new file mode 100644 index 000000000..8e9f2071f --- /dev/null +++ b/test/integration/pushTag/expected_remote/info/exclude @@ -0,0 +1,7 @@ +# git ls-files --others --exclude-from=.git/info/exclude +# Lines that start with '#' are comments. +# For a project mostly in C, the following would be a good set of +# exclude patterns (uncomment them if you want to use them): +# *.[oa] +# *~ +.DS_Store diff --git a/test/integration/pushTag/expected_remote/objects/0e/6cf0a6b79e8d44e186d812a1f74b43d64fac52 b/test/integration/pushTag/expected_remote/objects/0e/6cf0a6b79e8d44e186d812a1f74b43d64fac52 new file mode 100644 index 0000000000000000000000000000000000000000..7f2ebf4eeb6ad6875bcc2a2b91ca3345ee06b45e GIT binary patch literal 52 zcmb~ZE#08nZNMgRZ+ literal 0 HcmV?d00001 diff --git a/test/integration/pushTag/expected_remote/objects/90/5961711d3f0898c003c7e4da636a4c683f7934 b/test/integration/pushTag/expected_remote/objects/90/5961711d3f0898c003c7e4da636a4c683f7934 new file mode 100644 index 0000000000000000000000000000000000000000..f060761fd50dd1c6c424a86aac673ddff208770e GIT binary patch literal 119 zcmV--0Eqv10ga783WG2Z0DI0W_FgDi-L4Tz5j^>fHQ7+XB}Gzbe{Y`9ISvC8i`iBI zi7)j~1+N^l7hZ=^Ln2ZPoC0=&d7zd0#FQo8J13v|DhJF9JmzK6uh@InTP*ejcg?m*)jxA*zr5{=?gTN7EXizoG<^U7 literal 0 HcmV?d00001 diff --git a/test/integration/pushTag/expected_remote/objects/96/39a47a7955a338919b090835305898ea516c66 b/test/integration/pushTag/expected_remote/objects/96/39a47a7955a338919b090835305898ea516c66 new file mode 100644 index 0000000000000000000000000000000000000000..24378078363eed8cba9226652b5bead751e10083 GIT binary patch literal 149 zcmV;G0BZku0gaA93c@fDMP26<*$Xn0OeY->5xVLz(qw`KV@rvkw>L-dFCXv0Pg|{P zvnX_GhpLUi6UIRbpB!du)fDW_z9HyMAKbpL$7Ky;)>WLVak@hybS3eyZu8x~bo?KGm5YSywqg DRUAdc literal 0 HcmV?d00001 diff --git a/test/integration/pushTag/expected_remote/objects/a5/bce3fd2565d8f458555a0c6f42d0504a848bd5 b/test/integration/pushTag/expected_remote/objects/a5/bce3fd2565d8f458555a0c6f42d0504a848bd5 new file mode 100644 index 0000000000000000000000000000000000000000..285df3e5fbab12262e28d85e78af8a31cd0024c1 GIT binary patch literal 21 ccmb`~^A08nuUMF0Q* literal 0 HcmV?d00001 diff --git a/test/integration/pushTag/expected_remote/objects/a7/341a59f0ddeef969e69fb6368266d22b0f2416 b/test/integration/pushTag/expected_remote/objects/a7/341a59f0ddeef969e69fb6368266d22b0f2416 new file mode 100644 index 0000000000000000000000000000000000000000..96d2e71a6af75cdd27ac5d9628a27faecc40fb66 GIT binary patch literal 77 zcmV-T0J8sh0V^p=O;s>AU@$Z=Ff%bx$gNDv%tB=N-?^8o7KK;!x4hDxZ=ntVWIZ01*pecg literal 0 HcmV?d00001 diff --git a/test/integration/pushTag/expected_remote/packed-refs b/test/integration/pushTag/expected_remote/packed-refs new file mode 100644 index 000000000..31565c279 --- /dev/null +++ b/test/integration/pushTag/expected_remote/packed-refs @@ -0,0 +1,2 @@ +# pack-refs with: peeled fully-peeled sorted +9639a47a7955a338919b090835305898ea516c66 refs/heads/master diff --git a/test/integration/pushTag/expected_remote/refs/tags/v1.0 b/test/integration/pushTag/expected_remote/refs/tags/v1.0 new file mode 100644 index 000000000..442efe33e --- /dev/null +++ b/test/integration/pushTag/expected_remote/refs/tags/v1.0 @@ -0,0 +1 @@ +9639a47a7955a338919b090835305898ea516c66 diff --git a/test/integration/pushTag/recording.json b/test/integration/pushTag/recording.json new file mode 100644 index 000000000..7f2006f35 --- /dev/null +++ b/test/integration/pushTag/recording.json @@ -0,0 +1 @@ +{"KeyEvents":[{"Timestamp":1037,"Mod":0,"Key":259,"Ch":0},{"Timestamp":1596,"Mod":0,"Key":256,"Ch":93},{"Timestamp":1709,"Mod":0,"Key":256,"Ch":93},{"Timestamp":2117,"Mod":0,"Key":256,"Ch":110},{"Timestamp":2411,"Mod":0,"Key":256,"Ch":118},{"Timestamp":2757,"Mod":0,"Key":256,"Ch":49},{"Timestamp":2932,"Mod":0,"Key":256,"Ch":46},{"Timestamp":3109,"Mod":0,"Key":256,"Ch":48},{"Timestamp":3373,"Mod":0,"Key":13,"Ch":13},{"Timestamp":3988,"Mod":0,"Key":256,"Ch":80},{"Timestamp":4516,"Mod":0,"Key":13,"Ch":13},{"Timestamp":5309,"Mod":0,"Key":256,"Ch":113}],"ResizeEvents":[{"Timestamp":0,"Width":272,"Height":74}]} \ No newline at end of file diff --git a/test/integration/pushTag/setup.sh b/test/integration/pushTag/setup.sh new file mode 100644 index 000000000..5e09ed4ea --- /dev/null +++ b/test/integration/pushTag/setup.sh @@ -0,0 +1,26 @@ +#!/bin/sh + +set -e + +cd $1 + +git init + +git config user.email "CI@example.com" +git config user.name "CI" + +echo test1 > myfile1 +git add . +git commit -am "myfile1" +echo test2 > myfile2 +git add . +git commit -am "myfile2" + +cd .. +git clone --bare ./actual actual_remote + +cd actual + +git remote add origin ../actual_remote +git fetch origin +git branch --set-upstream-to=origin/master master diff --git a/test/integration/pushTag/test.json b/test/integration/pushTag/test.json new file mode 100644 index 000000000..2e194536b --- /dev/null +++ b/test/integration/pushTag/test.json @@ -0,0 +1 @@ +{ "description": "create and push tag to remote", "speed": 10 }