;;; magithub-proxy.el --- Fake repository context  -*- lexical-binding: t; -*-

;; Copyright (C) 2017  Sean Allred

;; Author: Sean Allred <code@seanallred.com>
;; Keywords: tools

;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.

;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;; GNU General Public License for more details.

;; You should have received a copy of the GNU General Public License
;; along with this program.  If not, see <http://www.gnu.org/licenses/>.

;;; Commentary:

;; Use a different repository context

;;; Code:

(require 'magit)

(defun magithub-proxy-set (remote)
  "Use REMOTE as the issue-tracker in this repository."
  (interactive (list (magit-read-remote "Issue-tracking remote")))
  (magit-set (unless (string= remote "origin") remote) "magithub" "proxy"))

(defun magithub-proxy-set-default (remote)
  "Use REMOTE as the default issue-tracker for all repositories.
If no issue-tracker is defined on a per-repo basis, this tracker is used.

This modifies global git-config."
  (interactive "sDefault remote name of issue-tracker (applies to all repositories): ")
  (and (magit-git-success "config" "--global" "magithub.proxy" remote)
       remote))

(provide 'magithub-proxy)
;;; magithub-proxy.el ends here
