Code Monkey home page Code Monkey logo

gitlib's Introduction

Gitonomy

Build Status

Gitonomy is a git repository management solution. It acts as a git server and offer you a web-interface to manage and browse your repositories.

How to install?

Go to the download page and get the last stable release of Gitonomy.

Uncompress the archive, and you will have a project with this structure:

app/
src/
vendor/
web/
README.md
install.sh

Put this folder where-ever you want and make your web-server use the web/ folder as document root.

You need to make sure that the application has full write-access to git repositories, even via web.

Two front controllers are used for administration: app_dev.php and install.php. Those two files, as default, are secured to only accept connections from localhost.

If you want to setup the application remotely, edit those files to fit with your policy. It's your responsability to secure those scripts. When you're done, access http://localhost/install.php and continue with step-by-step.

When it's done, you need to setup CRONTAB for recurring tasks:

* * * * * php /path/to/gitonomy/app/console authorized:keys -i > ~/.ssh/authorized_keys

That's it, your are now ready to use Gitonomy.

How to contribute?

If you are a developer and plan to contribute on Gitonomy, you need to checkout code on your computer and run the reset.sh script located at root of repository:

git clone [email protected]:gitonomy/gitonomy.git gitonomy
cd gitonomy
./reset.sh

gitlib's People

Contributors

fonsecas72 avatar grahamcampbell avatar hason avatar hostep avatar josephharrington avatar juanmcasanova avatar juliendidier avatar keradus avatar kingcrunch avatar lyrixx avatar ma-si avatar martin-helmich avatar mattketmo avatar midnightdesign avatar mokrypatrik avatar neemzy avatar neiluj avatar patrick-beuks avatar peter279k avatar phpfui avatar pitpit avatar robbieaverill avatar samail avatar seva-ask avatar simonhamp avatar tolik518 avatar ubermuda avatar urguardian4ngel avatar x-coder avatar xorti avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

gitlib's Issues

How can we contribute to documentation?

Hey,

There are a few places where parts are out of date, such as the diff section, file object (isNew() isDelete())... Should be isCreation() isDeletion()

And the references section $repository->getBranches(); should be $references->getBranches(); (along with the others that say $repository).

Is there anyway to contribute?

Problems with Applying and reverting patches

Hi,
My name is Furqan Ahmed and I am using gitonomy to manipulate git commands through php. All other things went fine while using gitonomy except I am stuck with applying and reverting patch. As there is no direct function in the library to apply and revert a patch so I am using run in repository.php file to run the commands. Following are the commands that I am using to apply and revert a patch file.

Applying a patch file
$repository = new Repository('../../../furqan-repositories/test-repository/remote-repository');
$patch = PATCH_FILES_FOLDER_PATH.'latest.patch';

    $otpt = $repository->run( 'apply', array( '../../../furqan-repositories/local-repository/patches/first_ever_patch.patch' ) );

Reverting a patch file

$repository = new Repository("c:/furqan-repositories/test-repository/remote-repository");
$otpt = $repository->run( 'apply', array( '-R', 'c:/furqan-repositories/local-repository/patches/first_ever_patch.patch' ) );

I am using the above code to apply and revert patches but the following exception is appearing :

Error while running git command:
"C:\Program Files (x86)\Git\bin\git.exe" "--git-dir" "C:\furqan-repositories\test-repository\remote-repository/.git" "--work-tree" "C:\furqan-repositories\test-repository\remote-repository" "apply" "../../../furqan-repositories/local-repository/patches/first_ever_patch.patch"

error: hello.txt: No such file or directory

The file that has been changed i.e., hello.txt could not be found. However through git bash I can easily apply and revert patches. Can any body please help me out with this issue.

Thanks and Regards,
Furqan Ahmed.

Error parsing diff Expected "rename from ", but got "copy from si"

Hey,

While I was viewing one of my diffs for a commit I got a

Expected "rename from ", but got "copy from si"

This error occurred because I copied pretty much my entire file from one from to another (but did a few changes, so git diff returned...

similarity index 97%
copy from style.css
copy to common.css

Similarity index can also be copy, it's not restricted to just renaming.

I'll see if I can get a pull request done. But how do you generally handle multiple options? I can't seem to find any other example. For now I just wrapped it in a try catch.

Configuration of repository

In git directory, there is a config file on which many great things can be operated:

  • fetch patterns
  • upstream settings
  • ...

This file is using a format looking like this:

[core]
    repositoryformatversion = 0
    filemode = true
    bare = false
    logallrefupdates = true
[remote "origin"]
    fetch = +refs/heads/*:refs/remotes/origin/*
    url = [email protected]:gitonomy/gitlib.git
[branch "master"]
    remote = origin
    merge = refs/heads/master

This file can be overriden by user's file (~/.gitconfig). Recently, environment variables have been disabled in process (thanks @lyrixx), so this disable fully the user's inherited configuration.

Two strategies can be imagined:

  1. Parse the file and allow manipulation of it
  2. Use git config command

error while running config output: """git"" ��...

tomjn/composerpress#4

I use this library in my WordPress plugin, and a user on Windows 7 x64 had this issue:

Getting this error in plugin's page (after admin menu, no other output):

Fatal error: in C:\server\www\dev\wp-content\plugins\composerpress\vendor\gitonomy\gitlib\src\Gitonomy\Git\Repository.php on line 550

Dumping what $error var holds around there nets this gem:

error while running config output: """git"" �� ���� ����७��� ��� ���譥� ��������, �ᯮ��塞�� �ணࠬ��� ��� ������ 䠩���. "

Win7x64

The error persists in current dev-master on line 559

WorkingStatus class missed

WorkingCopy class has method with body:

public function getStatus()
    {
        return WorkingStatus::parseOutput();
    }

But WorkingStatus class doesn`t exist

$commit->getTree();

$commit->getTree(); now returns a commit string rather than an instance of tree.

$tree->getEntries(); = Error "Call to a member function getEntries() on a non-object"

gitlib requires at least version 2.4.0 of symfony/process

Installing symfony/process:2.3.11 cause Repository object to throw the following exception:

Fatal error: Call to undefined method Symfony\Component\Process\Process::setIdleTimeout() in /.../vendor/gitonomy/gitlib/src/Gitonomy/Git/Repository.php on line 628

Process::setIdleTimeout has been created in the following commit:

symfony/process@fb8ca19

Symfony Process 2.4 dependency

In composer.json the Symfony Process components require version 2.4 or above, but a lot of projects use Symfony 2.3 because it is an LTS release. Is it possible to downgrade component versions to ^2.3?

Class don't exist Gitonomy\Git\WorkingStatus

I'm try to use the WorkCopy and get the status

<?php
  $copy = $repository->getWorkingCopy();
  $branch = $copy->checkout("2015May24-2018");

  ld($branch->getStatus());
Fatal error: Class 'Gitonomy\Git\WorkingStatus' not found in /vendor/gitonomy/gitlib/src/Gitonomy/Git/WorkingCopy.php on line 40

External test repositories

Repositories for testing should be moved outside of projects (foobar, barbaz, lib-repository in tests)

Status ? How to push, commit

Hi.

Is the project still maintained ?

I didnt find a way to push nor commit without 'Repository::run'. These are basic features, and i think it should be developped if not, or documented.

Get the files added in the first commit

Hi!

I am unable to get the diff/files for the first commit.
There is supposed to be a lot of file changes in this commit, but the diff is empty. Is there any other way to get the files added in this initial commit?

$git = new Repository("project");
$log = $git->getLog("master");
$commits = array_reverse($log->getCommits());
print_r($commits[0]->getDiff());

Unable to set prefix to ProcessBuilder

Hello,

In some environment, we need to add some prefix to ProcessBuilder.
Ex : sudo

For exemple, in Repository class ,
It would be nice to add a prefix_command option in the constructor :

public function __construct($dir, $options = array())
{
    ...
    $this->prefix_command = $options['prefix_command'];
    ...
}

And in the getProcess Method :

$builder = new ProcessBuilder(array_merge($base, $args));
if(!empty($this->prefix_command)) {
    $builder->setPrefix($this->prefix_command);
}

Thanks

Test against many git versions

Test suite should be ran against different versions.

git on my laptop: 1.7.10.4
git on my server: 1.7.2.5

It's OK if we test with only one version on Travis, until we can test locally with different versions.

Fatal error on server?

Hi I got:
"Fatal error: Uncaught exception 'Gitonomy\Git\Exception\ProcessException' with message 'Error while running git command: 'git' '--git-dir' '/home/davidshe/gitreview/git/login/.git' '--work-tree' '/home/davidshe/gitreview/git/login' 'cat-file' '-p' 'f1c54dea53090546ce4754d0a04d47e89457f5c9' error: inflate: data stream error (invalid distance too far back) fatal: loose object f1c54dea53090546ce4754d0a04d47e89457f5c9 (stored in /home/davidshe/gitreview/git/login/.git/objects/f1/c54dea53090546ce4754d0a04d47e89457f5c9) is corrupt ' in /home/davidshe/gitreview/vendor/gitonomy/gitlib/src/Gitonomy/Git/Repository.php:560 Stack trace: #0 /home/davidshe/gitreview/vendor/gitonomy/gitlib/src/Gitonomy/Git/Tree.php(46): Gitonomy\Git\Repository->run('cat-file', Array) #1 /home/davidshe/gitreview/vendor/gitonomy/gitlib/src/Gitonomy/Git/Tree.php(71): Gitonomy\Git\Tree->initialize() #2 /home/davidshe/gitreview/app/view/RepoView.php(241): Gitonomy\Git\Tree->getEntries() #3 /home/davidshe/gitreview/app/view/RepoView.php(76): RepoView->displa in /home/davidshe/gitreview/vendor/gitonomy/gitlib/src/Gitonomy/Git/Repository.php on line 560"

on server but on local, what should I do?

Driver support

Implement a system of driver for being able to switch between git calls and libgit2

Should also be useful when we want to implement networked git calls

Showing diff - added is displayed as deleted, and vice versa

When I try to show the differences in the files for a specific commit I encounter a problem.

Everything that has been added is displayed as deleted, and vice versa.
Not only wrong display but also wrong order.

$file->getAdditions() and $file->getDeletions() is also switched.

Here is the code I perform:

$commit = $this->gitRepository->getCommit($hash);
$diff = $this->gitRepository->getDiff($commit->getHash().'..'.$commit->getParentHashes()[0]);

foreach ($diff->getFiles() as $file) {
    foreach ($file->getChanges() as $change) 
    {
        echo '<pre><code class="">';
        foreach ($change->getlines() as $data) 
        {
            list ($type, $line) = $data;
            if ($type === FileChange::LINE_CONTEXT) {
                echo ' '.htmlentities($line)."\n";
            } elseif ($type === FileChange::LINE_ADD) {
                echo '+'.htmlentities($line)."\n";
            } else {
                echo '-'.htmlentities($line)."\n";
            }
        }
        echo '</code></pre>';
    }
}

The output:

      */
     public function __construct($view, $dependencyInjector = null)
     {
-        $parser = new \Baseapp\Library\Parsedown\ParsedownExtra();
+        $parser = new \Baseapp\Library\Markdown\MarkdownExtra();
+        $parser->code_attr_on_pre = true;
         $this->markdown = $parser;

         parent::__construct($view, $dependencyInjector);

Should be:

      */
     public function __construct($view, $dependencyInjector = null)
     {
-        $parser = new \Baseapp\Library\Markdown\MarkdownExtra();
-        $parser->code_attr_on_pre = true;
+        $parser = new \Baseapp\Library\Parsedown\ParsedownExtra();
         $this->markdown = $parser;

         parent::__construct($view, $dependencyInjector);

Showing deleted folders in diff

Is it possible to have git diff show removed / added folders rather than just the files inside the folders?

I made a deployment script based on the diff tool but I cant work out when a folder needs to be deleted only when the content of the folder is deleted.

Remotes

This issue is about handling of remote repositories in gitlib (poke @MattKetmo)

git fetch copy all tags and store them locally. It happens unless you specify git fetch --no-tags. Once they're downloaded, you can't distinguish them anymore from your local one.

You can get a full-list of references (:heart:) on a remote repository, but it costs a call to remote repository: git ls-remote origin.

References

The Symfony\Component\Process\ProcessBuilder::inheritEnvironmentVariables() method is deprecated

Since I did a composer update yesterday, I'm having this error:

The Symfony\Component\Process\ProcessBuilder::inheritEnvironmentVariables() method is deprecated since version 3.3 and will be removed in 4.0.
File: [...]/vendor/symfony/process/ProcessBuilder.php
Line: 128

My code triggering the error:

$repository->run('fetch', ['origin', '--tags']);

I'm using gitlib 0.1.8 and symfony/process 3.3.2.

The stack trace:

File: [...]/vendor/symfony/process/ProcessBuilder.php
Line: 128
Function: trigger_error

File: [...]/vendor/gitonomy/gitlib/src/Gitonomy/Git/Repository.php
Line: 622
Function: inheritEnvironmentVariables

File: [...]/vendor/gitonomy/gitlib/src/Gitonomy/Git/Repository.php
Line: 531
Function: getProcess

Git\Log makes way too much git calls

Right now, for a log of N commits, Git\Log makes N+1 git calls (one for the commit list, then one per commit). It could be reduced to 1 call by using the proper git log options

gitlib on windows, git error

Hi, I can't make gitlib work on windows 8 and i have put git in my paths get following error:
"git"' is not recognized as an internal or external command, operable program or batch file.

Why?

License conflict

The file header states GPL as license, but the compose.json and LICENSE say MIT. This is bad, because now it is unclear which license is valid.

I'd suggest to remove the header from every file, because they don't serve any special purpose (the LICENSE is enough). I hope you will go with MIT, because the GPL would make it unusable for me. However, if you choose GPL you must add the version.

Missing merge command

Is there a reason that there is no implementation for git merge? If no reason, would you be open for a PR adding this behavior?

Get Exception "Error while getting list of references"

I'm using Glit which uses gitlib. I get the following RuntimeException :

RuntimeException: Error while getting list of references -
in /home/vince/public_html/glit/vendor/gitonomy/gitlib/src/Gitonomy/Git/ReferenceBag.php at line 297 -

After some research, I found that this is in the initialize method, at the line 295 $e->getErrorOutput(); which give me a null value.

The catched exception at line 293 is the following :

Error while running git command:
'git' '--git-dir' '/var/www/repositories/vince/vd-angular-calendar.git' 'show-ref' '--tags' '--heads'

What could be the reason that I get this exception ?

Support for annotated tags?

It seems like the current implementation picks up normal (lightweight) tags but skips over annotated tags.

I noted that in ReferenceBag->initialize() it's calling git show-ref. When I run this at the command line, I see that annotated tags actually have a different hash than the commit they point to, which I'm guessing is what's causing them to get skipped.

Repro steps:

echo hello > a.txt
git init && git add . && git commit -m "Initial"

git tag "normal-tag"
git tag -a "annotated-tag"
$repo = new Repository('~/gitlibtest');
$commit = $repo->getRevision('HEAD')->getCommit();
$tags = $repo->getReferences()->resolveTags($commit);

count($tags);  // 1
$tags[0]->getName();  // "normal-tag"

debug mode

What about adding a $debug parameter to Repository constructor that would affect the following behaviors:

  • add a public method Repository::isDebug to know in subclasses the policy to have (for parsing and sub-tasks)
  • when an error happens on git commands, return null if debug is disabled. Throws an exception if return code is not zero

In development, that would help you seeing edge cases. Recently, on Commit object, @lyrixx added a method getIncludingBranches. In it, if requested with a wrong object hash, execution fails. Debug mode would help here to see edge cases, why it's called with a wrong hash.

In production, it would silently crash, in a deathful logic pain.

[RFC] Added support for diff serialization

Hello.

It could be fine to have an elegant way to serialize/deserialize a Diff to store it in a database (for exemple).
I have to store it in DB because my repository can not longer exist :(

We could use symfony/serializer. Of course, it's not the responsibility of gitlib to serialize itself. But we can add convenient methods / interfaces to make it easier.

For now, it's not very possible, because every object have a dependency to Repository object.

BTW, if we do that, we should consider to add serialization for object.

What do you think ?

Run a command?

Hello,

Is there a way to run a command on the git repo... I need to see how many files changed before I attempt to do a diff, as anything more then say 800 files seems to be exhausting my memory (256mb).

Something like...

git whatchanged aa32064 --format=oneline | wc -l

I tried the shell function and ended up getting an error about undefined constant STDIN.

No match for regexp /diff --git (a\/.*) (b\/.*)\n/

Hello,

I would like to use GrumPHP. However after installation, and trying to perform a commit I get the following error:

[Gitonomy\Git\Exception\RuntimeException]                                                    
  No match for regexp /diff --git (a\/.*) (b\/.*)\n/ Upcoming: diff --git c/composer.json i/c

screen shot 2016-07-28 at 16 03 50

I started by posted the issue on the grumphp repository, who suggested me to post here. phpro/grumphp#164 (comment)

Thanks,

No commit message = issues

Very rare, but possible.

When logging a repository that has a commit with no commit message.

screen shot 2014-05-22 at 18 45 57 1x

$this->content = 


commit 4d58c86cfbe69bba817775ca13794c6ef4543d7e
tree 501a51b6fd37ca3486346439e9f6866168aa1e19
parent 650670073cf5051d00421f59f001c58f6fe741bf
parent 31ab9665b96a85b887c362e39362d4530e9ab338
author philipclifton <[email protected]> 1400586247 +0100
committer philipclifton <[email protected]> 1400586247 +0100

    Merge remote-tracking branch 'origin/staging' into staging

commit 650670073cf5051d00421f59f001c58f6fe741bf
tree dcaeb301cef9ea57fc6dd1959bcf1026c9af205c
parent d4fcb008a822da8e777612cdf7013a7eae1df827
author philipclifton <[email protected]> 1400586096 +0100
committer philipclifton <[email protected]> 1400586096 +0100

    add crons

commit 31ab9665b96a85b887c362e39362d4530e9ab338
tree c8a4523947be4f8f7ee98e49be041929a8b2cba8
parent d4fcb008a822da8e777612cdf7013a7eae1df827
author Andy Gilbert <[email protected]> 1400585521 +0000
committer Andy Gilbert <[email protected]> 1400585521 +0000

commit d4fcb008a822da8e777612cdf7013a7eae1df827
tree b35fdabaac1d5a5572aa82fd7ded9e05a9c3bd23
parent 766e51ae4d27bb0abbe6707950fa7962221e184b
author philipclifton <[email protected]> 1400577338 +0100
committer philipclifton <[email protected]> 1400577338 +0100

    change contact phone number

commit 766e51ae4d27bb0abbe6707950fa7962221e184b
tree 446f561a9c0e1e46a30e27f0f5caf73438739d24
parent 3bae15039da08833d69b3c096c4d9936fcfc38cb
author philipclifton <[email protected]> 1400505454 +0100
committer philipclifton <[email protected]> 1400505454 +0100

    fix the line effecting the sagepay gateway.

    It now compares the price with or without taxes with the amount paid

commit 3bae15039da08833d69b3c096c4d9936fcfc38cb
tree 8875da1842ef585da44fefa65c0dee9afd26a44c
parent c69ea07c352e40a9ec74af8e900f2bf8f95b665b
author philipclifton <[email protected]> 1400497827 +0100
committer philipclifton <[email protected]> 1400497827 +0100

    fix error in url

commit c69ea07c352e40a9ec74af8e900f2bf8f95b665b
tree 0cb3cc9ab731a423bb083a3dde6c0a245e642228
parent 048e82e03873cec8f2b96fa98add1ca5ddca8dca
author philipclifton <[email protected]> 1400497435 +0100
committer philipclifton <[email protected]> 1400497435 +0100

    remove debug

commit 048e82e03873cec8f2b96fa98add1ca5ddca8dca
tree 42f1581b49e40e57df31c9031b30b39480f90c0d
parent d2f475a82879d4d8847166e3932bdf9543b20b26
author philipclifton <[email protected]> 1400497322 +0100
committer philipclifton <[email protected]> 1400497322 +0100

    remove debug

commit d2f475a82879d4d8847166e3932bdf9543b20b26
tree 7efb534b7c416edd4298d26a6f822c56cfa54201
parent 747c52612761aecc92973459d4e14f6f069bbe61
author philipclifton <[email protected]> 1400496997 +0100
committer philipclifton <[email protected]> 1400496997 +0100

    debug

commit 747c52612761aecc92973459d4e14f6f069bbe61
tree 42f1581b49e40e57df31c9031b30b39480f90c0d
parent c47ef1e1e0780adb5cee513265f75640f10a27e4
author philipclifton <[email protected]> 1400495969 +0100
committer philipclifton <[email protected]> 1400495969 +0100

ssh-agent compatibility

I'm writing a command line utility for the Symfony console that would pull code from a few repositories, but it looks like that git when run through gitlib is not querying the running ssh-agent. I have tried forwarding the existing environment when creating a repository using the environment_variables option key (by just passing the SSH_AUTH_SOCK variabe and by passing the whole $_SERVER array) but it still would ask me for my passphrase for every repo I'm trying to fetch. I'm on ubuntu 16.04. Am I doing something wrong?

Gitonomy doesn't find git

For some reason Gitonomy doesn't seem to be able to find git in my path although it is there and works in both Git Bash and cmd. Can this be a Gitonomy problem or does it comes from the Process lib ?

PATH on windows

In the Repository constructer there is following default option:

'environment_variables' => $is_windows ? array( 'PATH' => $_SERVER['PATH'] ) : array(),

This causes a notice on windows:

Notice: Undefined index: PATH in ...../Repository.php on line 123

The path variable can be accessed as following:

getenv('PATH') ?: getenv('Path')

Error parsing signed git commits

gitlib throws an Exception when trying to parse a git commit that has been gpg signed. The exception message is:
[Error] Uncaught Gitonomy\Git\Exception\RuntimeException: Expected " ", but got "g" (gpgsig ---) /path/to/webroot/gitonomy/gitlib/src/Gitonomy/Git/Parser/ParserBase.php:111

Had a quick look through CommitParser.php and can't see anything there about GPG-signed commits. I'll try and write a patch for this, but in case I run out of time, I thought at least logging the issue would be good :)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.