Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug: not all git remotes are called "origin" #602

Closed
3 tasks done
sbaildon opened this issue Feb 28, 2023 · 4 comments · Fixed by #601
Closed
3 tasks done

bug: not all git remotes are called "origin" #602

sbaildon opened this issue Feb 28, 2023 · 4 comments · Fixed by #601
Labels
bug Something isn't working

Comments

@sbaildon
Copy link
Contributor

Did you check docs and existing issues?

  • I have read all the lazy.nvim docs
  • I have searched the existing issues of lazy.nvim
  • I have searched the existing issues of plugins related to this issue

Neovim version (nvim -v)

NVIM v0.9.0-dev-f43fa30

Operating system/version

macOS 13

Describe the bug

Actions involving plugin git repositories don't work after initial clone because lazy is hardcoded to look for a remote called "origin"

function M.get_origin(repo)
return M.get_config(repo)["remote.origin.url"]
end

I have a git config a custom remote name, which causes issues with updating, syncing etc.

[clone]
  defaultRemoteName = upstream

Steps To Reproduce

  1. git config --global clone.defaultRemoteName upstream
  2. ...install plugins with Lazy
  3. Open neovim, <cmd>Lazy<cr>
  4. C for Check
  5. see an error like, ...l/share/nvim/lazy/lazy.nvim/lua/lazy/manage/task/git.lua:137: attempt to concatenate local 'origin' (a nil value)
  6. revert to default origin git config --global --unset clone.defaultRemoteName

Expected Behavior

Lazy can update, sync, and check plugins without errors

Repro

-- DO NOT change the paths and don't remove the colorscheme
local root = vim.fn.fnamemodify("./.repro", ":p")

-- set stdpaths to use .repro
for _, name in ipairs({ "config", "data", "state", "cache" }) do
  vim.env[("XDG_%s_HOME"):format(name:upper())] = root .. "/" .. name
end

-- bootstrap lazy
local lazypath = root .. "/plugins/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
  vim.fn.system({ "git", "clone", "--filter=blob:none", "https://github.com/folke/lazy.nvim.git", lazypath, })
end
vim.opt.runtimepath:prepend(lazypath)

-- install plugins
local plugins = {
  "folke/tokyonight.nvim",
  -- add any other plugins here
}
require("lazy").setup(plugins, {
  root = root .. "/plugins",
})

vim.cmd.colorscheme("tokyonight")
-- add anything else here
@sbaildon sbaildon added the bug Something isn't working label Feb 28, 2023
@folke folke closed this as completed in 5af9380 Feb 28, 2023
@folke
Copy link
Owner

folke commented Feb 28, 2023

Haven't tested it, but this should fix it. Let me know if it doesn't

@sbaildon
Copy link
Contributor Author

sbaildon commented Mar 5, 2023

#5af9380 isn't a full fix, the check path fails to build the correct config key because clone.defaultRemoteName is a property of a global config, not a local repo

local origin = Git.get_origin(self.plugin.dir)

@folke
Copy link
Owner

folke commented Mar 5, 2023

sorry, but this is out of scope for lazy. I'm not going to spend more time on this. Not something a lot of people will use anyway

sbaildon added a commit to sbaildon/lazy.nvim that referenced this issue Mar 5, 2023
folke pushed a commit that referenced this issue Mar 5, 2023
* fix(git): force origin name

* Revert "fix(git): honor clone.defaultRemoteName. Fixes #602"

This reverts commit 5af9380.
@lougreenwood
Copy link

lougreenwood commented Nov 15, 2023

I got hit by this issue yesterday when setting up AstroNvim with a local copy of their AstroCommunity repo of packages which recommends using an upstream remote.

It seems overly fragile to require that the remote is called origin. It's not at all unusual for a forked repo to have both an origin remote which represents the fork and an upstream remote for the master/main branch which corresponds to the upstream project. This makes it easy to always checkout the upstream master branch and keep things in sync.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants