Beispiel #1
0
func indexCommit(inCommit objects.Commit) {
	indexBlob(inCommit.Bytes())
	hashHex := inCommit.Hash().Hex()
	blobIndex[hashHex] = blobIndex[hashHex].insertType("Commit")
	blobIndex[inCommit.Hkid.Hex()] =
		blobIndex[inCommit.Hkid.Hex()].insertType("Repository")
	blobIndex[hashHex] =
		blobIndex[hashHex].insertCollection(inCommit.Hkid.Hex())
	if _, present := blobIndex[inCommit.ListHash.Hex()]; !present {
		blobIndex[inCommit.ListHash.Hex()] =
			blobIndexEntry{HCID: inCommit.ListHash.Hex()}
	}
	blobIndex[inCommit.ListHash.Hex()] =
		blobIndex[inCommit.ListHash.Hex()].insertRefCommits(hashHex)

	if commitIndex == nil {
		commitIndex = make(map[string]commitIndexEntry)
	}
	if _, present := commitIndex[inCommit.Hkid.Hex()]; !present {
		commitIndex[inCommit.Hkid.Hex()] = commitIndexEntry{}
	}
	commitIndex[inCommit.Hkid.Hex()] =
		commitIndex[inCommit.Hkid.Hex()].insertVersion(
			inCommit.Version,
			inCommit.Hash(),
		)
	insertDescendantS(inCommit.Parents, inCommit.Hash(), inCommit.Version)
}
Beispiel #2
0
func (lfs localfileservice) PostCommit(c objects.Commit) (err error) {
	lfs.PostBlob(objects.Blob(c.Bytes()))
	filepath := fmt.Sprintf("bin/commits/%s/%d", c.Hkid.Hex(), c.Version)
	//log.Printf("[localfileservice] PostCommit %s\n\t%d", filepath, c.Version())
	dirpath := fmt.Sprintf("bin/commits/%s", c.Hkid.Hex())
	err = os.MkdirAll(dirpath, 0764)
	err = ioutil.WriteFile(filepath, c.Bytes(), 0664)
	return
}
Beispiel #3
0
func (k kademliaservice) PostCommit(c objects.Commit) (err error) {
	values := url.Values{}
	values.Add("type", "commit")
	values.Add("hkid", c.Hkid.Hex())
	data, err := k.postobject(values, c.Bytes())
	if err != nil {
		log.Println(err)
		log.Printf("%s", data)
		return err
	}
	return err
}