Skip to content

Latest commit

 

History

History
78 lines (50 loc) · 2.5 KB

README.md

File metadata and controls

78 lines (50 loc) · 2.5 KB

GITTP

GoDoc Go Walker Gocover Go Report Card Build Status

Host your own git server over HTTP. Effortlessly hook into pre and post receive events and write status updates back to the client.

Comes in CLI and Library flavors.

I used this doc and this handy blog post

How to CLI

Simply run gittp at your command line after installing the binary into your $PATH.

Available args:

-port: The port that gittp listens on

-path: Specify a file path where pushed repositories are stored. If this folder doesn't exist, gittp will create it for you

-masterOnly: Only permit pushing to the master branch

-autocreate: Auto create repositories if they have not been created

-debug: turns on debug logging

How to Library

Install:

go get gopkg.in/adamveld12/gittp.v1

This lib follows http.Handler conventions. I purposely do not include any authentication, since there are many http basic authentication modules out there to use.

package main

import (
  "net/http"
  "github.com/adamveld12/gittp"
)

func main() {
	config := gittp.ServerConfig{
    Path: "./repositories",
    PreCreate: gittp.UseGithubRepoNames,
    PreReceive: gittp.MasterOnly,
    PostReceive: func(h gittp.HookContext, archive io.Reader){
      h.Writef("Woohoo! Push to %s succeeded!\n", h.Branch)
    }
  }

  handle, _ := gittp.NewGitServer(config)
  log.Fatal(http.ListenAndServe(":80", handle))
}

Contributing

All contributions, critiques and questions are welcome.

License

MIT