-
-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[WIP] Git support: first steps #109
base: master
Are you sure you want to change the base?
Conversation
Thanks for your pull request, @wilzbach! |
That seems like overkill. Why not just use a bare repo? |
auto remoteDir = pr.repoURL; | ||
|
||
logInfo("[git/%s]: cloning branch %s...", pr.repoSlug, targetBranch); | ||
auto pid = spawnShell("git clone -b %s %s %s".format(targetBranch, remoteDir, uniqDir)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
spawnProcess > spawnShell in all situations, unless you need to use a shell built-in or run a user-supplied shell command
source/dlangbot/git.d
Outdated
//pid.wait; | ||
import vibe.core.core; | ||
import core.time; | ||
sleep(60.seconds); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is just to test things - as explained if I use wait
Vibe.d blocks entirely (and thus even the dummy git server backend doesn't answer).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Vibe really needs an async wait for processes. I considered using Vibe for a project before I discovered it didn't have this. In any case, you can always wait in a thread.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Vibe really needs an async wait for processes. I considered using Vibe for a project before I discovered it didn't have this
Do you care enough to write an issue?
In any case, you can always wait in a thread.
I tried that before, it didn't work, but I will try again tonight.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried that before, it didn't work, but I will try again tonight.
It's really bizarre if that wouldn't work. If it comes to that, you could always create a native pthread that not even the D runtime knows about.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you care enough to write an issue?
Where would I even file it? I think it needs to be implemented in the driver. It needs to be implemented as a SIGCHILD handler on POSIX and WaitFor*Object*
on Windows.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
std.process.wait seems to block the entire Vibe.d thread even if we are in a new fiber
BTW, zero surprise there - the fiber is not going to return to the scheduler because wait
is a blocking OS API essentially.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Think you can use a file event descriptor combined with tryWait.
Function createFileDescriptorEvent - vibe.d
fcntl(p.stdout.fileno, F_SETFL, O_NONBLOCK);
scope readEvt = createFileDescriptorEvent(p.stdout.fileno, FileDescriptorEvent.Trigger.read);
while (readEvt.wait(5.seconds, FileDescriptorEvent.Trigger.read))
{
auto rc = tryWait(p.pid);
if (rc.terminated)
{ /* do something */ }
}
Think the event will trigger when the process terminates, not too sure though.
Where would I even file it? I think it needs to be implemented in the driver. It needs to be implemented as a SIGCHILD handler on POSIX and WaitForObject on Windows.
On the issue tracker? vibe-d/vibe.d#1832
Combining signalfd, epoll, and handling SIGCHILD shouldn't be too hard, but maybe you can leave some more details on that issue. Indeed async subprocesses would be a welcome addition.
Shouldn't be too hard to add, and since you
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Think you can use a file event descriptor combined with tryWait.
Yeah, timers (and threads) are always a solution, but such an unsatisfying one.
Timers are imprecise, and threads are not cheap.
Combining signalfd, epoll, and handling SIGCHILD shouldn't be too hard, but maybe you can leave some more details on that issue.
I started a thread on D.learn a while ago here, it should have some useful discussion and links: http://forum.dlang.org/post/[email protected]
Shouldn't be too hard to add, and since you
Did you mean to add something here?
Why? I explicitly want to test what the bot will send to GitHub, so mocking the API seemed very reasonable. |
Well, it tests implementation detail of third-party software, relies on the git implementation used to behave as it does now, and it would make it overly onerous to write tests for more complicated functionality in the same vein. It would make sense if dlang-bot had its own git client and SmartGit protocol implementation, but it doesn't (and shouldn't) - it uses the git shell commands, so I think it would be more logical to test their effects, not implementation details. IMHO. shrug |
How would you test the effect of |
You can push to a bare repo on the filesystem. |
What do you guys think about using comments, instead of labels for this? Specifically about squashing, it would be much better if a reviewer could manually specify a commit message. |
I kindof like the idea of giving some functionality to contributors through the comments. If you want to build the basic infrastructure around labels, you could still have commands in the comments to label/unlabel a PR. |
This is a WIP approach to support to new features.
Based on a label (or maybe comment, but label is easier for now as authorization is implicitly given), support the following "actions":
Imho both are very useful features
This PR implements only "rebase", but adding "squash" later won't be difficult
What's there?
This means that we can fully handle
git push
commands as "faked" server, inject the requests and control the responses like we already do for other mocked APIs.The command will be handled by the mocked backend :)
What's missing?
std.process.wait
seems to block the entire Vibe.d thread even if we are in a new fiber (e.g.runTask
), on a worker thread (e.g.runWorkerTask
) and when spawned with std.concurrency`)gitURL