Previous: , Up: Initial Setup   [Contents][Index]


2.5 Setup a Partially Supported Host

Forge currently only supports the Github and Gitlab APIs.

It does however partially support a few additional forge types (see Partially Supported Forges) and other lighter weight software used to host Git repositories, which also provide a web interfaces (see Supported Semi-Forges). Forge doesn’t use the APIs of such forges, but registring the host and adding repositories to the local database at least enables the use of commands such as forge-browse.

Tell Forge about the Instance

A few hosts, which use partially supported forge types, are available out-of-the-box, because they have an entry in the default value of option forge-alist (also see its docstring). For example, the entry for https://github.com in that variable looks like this:

("codeberg.org"                     ; GITHOST
 "codeberg.org/api/v1"              ; APIHOST
 "codeberg.org"                     ; WEBHOST and INSTANCE-ID
 forge-gitea-repository)            ; CLASS

To be able to add repositories from a, so far, unknown forge instance to your local database, you have to add an entry for that instance to forge-alist. For example, assuming you use another Gitea instance, hosted at https://example.com, this might be correct:

(push '("example.com"               ; GITHOST
        "example.com/api/v1"        ; APIHOST
        "example.com"               ; WEBHOST and INSTANCE-ID
        forge-gitea-repository)     ; CLASS
      forge-alist)

Look at forge-alist entries of other hosts using the same forge type as the instance you are configuring, to see what format might be appropriate. You should be able to easily determine and verify GITHOST and WEBHOST, but determining APIHOST is more difficult; you might have to ask a colleague. APIHOST could be something like example.com/api/vi, but it could also be something like api.example.com.

Add Support for Additional Forge Types

For each fully or partially supported forge type, Forge defines at least a class. The following example is taken from forge-semi.el:

(defclass forge-cgit-repository (forge-noapi-repository)
  ((commit-url-format :initform "https://%h/%p.git/commit/?id=%r")
   (branch-url-format :initform "https://%h/%p.git/log/?h=%r")
   (remote-url-format :initform "https://%h/%p.git/about"))
  "Cgit from https://git.zx2c4.com/cgit/about.
Different hosts use different url schemata, so we need multiple
classes.  See their definitions in \"forge-semi.el\".")

Once you add a host using that class to forge-alist and then a repository from that host to the local database, you will be able to use commands such as forge-browse-branch (but not much more).

If you want to add a repository from another host, which happens to use another software or another URL schemata, then you might have to define an additional class first. See forge-semi.el for simple examples and grep for defclass forge-.*-repository for more complex ones.


Previous: Setup for Another Gitlab Instance, Up: Initial Setup   [Contents][Index]