Comments (7)
I think the confusion of methods underlays the issue: #52
The clone() method uses proc_open() instead of exec.
This then, is the third method of executing a command.
Ideally, all execution of the git command should be via the same 'runner' method which captures output and returns it. The caller method can decide whether it wants to process the output or not.
Consider creating a CmdResult object and return that from the 'runner' method. The object, a simple data object can hold the command result code + any output etc.
from git-php.
Thank you for this one too! :)
from git-php.
2. GitRepository::run()
vs GitRepository::execute()
Can you tell me about the differences between run()
and execute()
? When should execute()
be used instead of run()
? It seems to me that run()
is an internal method not designed to be called outside of GitRepository
, which is logical as run()
does not call begin()
and end()
methods to switch the current working directory, which should be done every time a command is run.
execute()
does call begin()
and end()
. And it takes different parameters than run()
. execute()
must be passed the command without the git
prefix, and a command is defined as an array of strings. Examples:
- To execute
git status
, you would callexecute(['status'])
orrun('git status')
. - To execute
git commit -m 'Hello world!'
, you would callexecute(['commit', '-m' => 'Hello world!'])
orrun('git commit', ['-m' => 'Hello world!'])
.
Why the methods do not use similar parameters?
Then one thing is the code inside the methods. Both methods are very similar on what they do, but the code is partly repeated:
Lines 656 to 668 in b5e709f
Lines 550 to 569 in b5e709f
Shouldn't execute()
call run()
instead of calling processCommand()
and exec()
? It seems to me that it would be more DRY :).
Is there any other differences between run()
and execute()
that I haven't noticed? :)
from git-php.
3. Every command method must pass the main command "git" to run()
For example run("git commit", ...)
:
Lines 363 to 375 in b5e709f
To me it seems that the main command git
is repeated unnecessarily. It's not easy to change the main command if one would need to. For example, if git
is not defined in the shell user's $PATH
, a developer might want to prefix the main command with a path, for example /path/to/git
. Or maybe even use a bash script as a wrapper around git to do some customizations (i.e. log all commands that were ran).
Could we change run()
so that it wouldn't require the caller to prefix the command with "git "? run()
is a protected function, so maybe this will cause some backwards compatibility issues? But not as bad as it would do if the method was public? Maybe this change could go to version 4.0?
from git-php.
Hello! Thanks for summary. I know about it, I plan solve it in version 4.0 (see #18 and #39), but I'm currently very busy.
GitRepository::run()
vs. exec()
I think exec()
is used in places where we need to work with output of command, because run()
method cannot return output.
GitRepository::run()
vs GitRepository::execute()
The run()
method is internal and I plan remove it in version 4.x. The execute()
method is public interface for running of commands by users, it can return output.
from git-php.
Ok, thanks for clarification. :)
from git-php.
Fixed 72f177e. Now we use only proc_open()
.
from git-php.
Related Issues (20)
- git remote HOT 1
- Can't install this package HOT 1
- Return type annotations erroneously specify self HOT 1
- Is this library production ready? HOT 1
- Is this library using the PHP exec() function to run git command? HOT 3
- Issue with big repos and branch listings HOT 2
- getLastCommitId fails HOT 1
- checkout with depth HOT 4
- Can we access the private repositories with username and password. ? HOT 5
- How do we get list of modified Files and removed files from local Repo ? HOT 1
- Git Commit Command Fails (Exit Code 1) HOT 3
- Authentication failed with Bitbucket private repository HOT 1
- --end-of-options is not supported on git 2.35.1 and 2.25.1 HOT 20
- How to log the output of the Git commands? HOT 1
- Class to get config properties
- Git command failed (exit-code 129) unknown option: 'end-of-option' HOT 2
- Command 'git add --end-of-options '/media/mehdi/inwork/newsample/readme.txt'' failed (exit-code 128). HOT 3
- sample of Clone HOT 4
- Github connection tester does not work through http HOT 2
- Setting environment variables for git command HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from git-php.