Skip to content

git-link--remote: fallback to existing remote rather than origin #137

@mooseyboots

Description

@mooseyboots

if git-link--remote fails to find a remote, it tries to fallback to origin.

i have repos with no origin but that do have remotes. in such cases doesn't it make sense to fallback to an actually existing remote, even just the first result of git-link--remotes, rather than a hardcoded option?

e.g.

(defun git-link--remote ()
  (let* ((branch (git-link--current-branch))
	 (remote (or (git-link--get-config "git-link.remote")
		     git-link-default-remote
		     (git-link--branch-remote branch)
                     (car (git-link--remotes))))) ;; Fallback to first remote if all else fails

    ;; Git defaults to "." if the branch has no remote.
    ;; If the branch has no remote we try master's, which may be set.
    (if (or (null remote)
	    (and (string= remote ".")
		 (not (string= branch "master"))))
	(setq remote (git-link--branch-remote "master")))

    (if (or (null remote) (string= remote "."))
	"origin"
      remote)))

i just started using git-link, so not sure if this would make sense in the library/for other users.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions