Skip to content
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

Problem with deploy command #168

Open
pnowy opened this issue Jun 14, 2016 · 6 comments
Open

Problem with deploy command #168

pnowy opened this issue Jun 14, 2016 · 6 comments

Comments

@pnowy
Copy link
Contributor

pnowy commented Jun 14, 2016

Hi,

I was trying to use Couscous as documentation tool for my project. Currently I'm using the Jekyll to generate page documentation so I have gh-pages branch and some content on that branch(my project site http://pnowy.github.io/NativeCriteria/).

At first when I've run the deploy command some content was generated to the gh-pages branch but the page wasn't replaced (during the process I've received console message that symphony doesn't have access to AppData/Local/Temp) and I end with the old files and .couscous/generated directory (see here https://github.com/pnowy/NativeCriteria/tree/gh-pages).

So I've tried to run second time the deploy command (I'm running this on windows so I've run the console one more time with admin rights) but this time I have the following message:

[RuntimeException]
Unable to create the branch 'gh-pages'
fatal: A branch named 'gh-pages' already exists.

Is it correct behavior? I don't think so because this branch has to exist. I'm using the latest version of couscous (1.5.2).

Thanks for your help.

When I deal with this problem I'm planning to create pull request regarding new template (see https://github.com/pnowy/CouscousNativeTemplate)

@mnapoli
Copy link
Member

mnapoli commented Jun 14, 2016

Hi! Have you managed to get it working? I see http://pnowy.github.io/NativeCriteria/ looks really good. Back to your issues:

during the process I've received console message that symphony doesn't have access to AppData/Local/Temp

My guess is that the generation went well (it happens in .couscous/generated) but the deployment failed because it tried to create a temp folder (see https://github.com/CouscousPHP/Couscous/blob/master/src/Deployer.php#L61-L69) but didn't have the rights.

I don't remember why we don't try to deploy by creating a subfolder in .couscous/, maybe we should do this?

Do you have a more complete log for the error? You could try running the command with the -v option so that it's more verbose.

[RuntimeException]
Unable to create the branch 'gh-pages'
fatal: A branch named 'gh-pages' already exists.

Related code: https://github.com/CouscousPHP/Couscous/blob/master/src/Deployer.php#L82-L91

  • try to checkout gh-pages
  • if error, try to create gh-pages

I think what happened is that checking out the target branch failed for some reason, but not because the branch didn't exist (because obviously it exists). But we interpret all failures as "the branch doesn't exist", which isn't really good.

What we could do is handle better the git checkout and possible failures.

@pnowy
Copy link
Contributor Author

pnowy commented Jun 15, 2016

Hi,

the current NativeCriteria page was built with Jekyll but I wanted to switch to Couscous because I easily could keep everything in one repo so I prepared my own template (mentioned https://github.com/pnowy/CouscousNativeTemplate) but the NativeCriteria page doesn't use it yet (I still use Jekyll - read next so you will figure out why) I've finally put it manually not by deploy command.

Today I've tried to execute couscous deploy one more time.

At first time I've received the error:

  [RuntimeException]
  Unable to create the branch 'gh-pages'
  fatal: A branch named 'gh-pages' already exists.

Exception trace:
 () at C:\Users\przemek\AppData\Roaming\Composer\vendor\couscous\couscous\src\Deployer.php:89
 Couscous\Deployer->checkoutBranch() at C:\Users\przemek\AppData\Roaming\Composer\vendor\couscous\couscous\src\
 Couscous\Deployer->deploy() at C:\Users\przemek\AppData\Roaming\Composer\vendor\couscous\couscous\src\Applicat
 Couscous\Application\Cli\DeployCommand->execute() at C:\Users\przemek\AppData\Roaming\Composer\vendor\symfony\
 Symfony\Component\Console\Command\Command->run() at C:\Users\przemek\AppData\Roaming\Composer\vendor\symfony\c
 Symfony\Component\Console\Application->doRunCommand() at C:\Users\przemek\AppData\Roaming\Composer\vendor\symf
 Symfony\Component\Console\Application->doRun() at C:\Users\przemek\AppData\Roaming\Composer\vendor\symfony\con
 Symfony\Component\Console\Application->run() at C:\Users\przemek\AppData\Roaming\Composer\vendor\couscous\cous

It looks that on each time you are trying to checkout remote gh-pages branch and on try/catch you assume that branch doesn't exist what is not totally correct because we have here the situation that local branch exist and that's why I cannot create branch and going to second try/catch (line 89 on Deployer). We should make git pull for this branch here in my opinion to have it up-to-date before commit and push.

So the first point: I think that deploy needs to be extended here about this additional case.

After this situation I've made second approach - I've just removed the local gh-pages branch I've run couscous deploy one more time (to be clear without any changes on my files).

This time I received the message:

[Couscous\CommandRunner\CommandException]
  On branch gh-pages
  Your branch is up-to-date with 'origin/gh-pages'.
  nothing to commit, working directory clean

Exception trace:
 () at C:\Users\przemek\AppData\Roaming\Composer\vendor\couscous\couscous\src\CommandRunner\CommandRunner.php:29
 Couscous\CommandRunner\CommandRunner->run() at C:\Users\przemek\AppData\Roaming\Composer\vendor\couscous\couscous\src\CommandRunner\Git.php:61
 Couscous\CommandRunner\Git->run() at C:\Users\przemek\AppData\Roaming\Composer\vendor\couscous\couscous\src\CommandRunner\Git.php:39
 Couscous\CommandRunner\Git->commitAllChanges() at C:\Users\przemek\AppData\Roaming\Composer\vendor\couscous\couscous\src\Deployer.php:111
 Couscous\Deployer->commitChanges() at C:\Users\przemek\AppData\Roaming\Composer\vendor\couscous\couscous\src\Deployer.php:54
 Couscous\Deployer->deploy() at C:\Users\przemek\AppData\Roaming\Composer\vendor\couscous\couscous\src\Application\Cli\DeployCommand.php:110
 Couscous\Application\Cli\DeployCommand->execute() at C:\Users\przemek\AppData\Roaming\Composer\vendor\symfony\console\Command\Command.php:259
 Symfony\Component\Console\Command\Command->run() at C:\Users\przemek\AppData\Roaming\Composer\vendor\symfony\console\Application.php:844
 Symfony\Component\Console\Application->doRunCommand() at C:\Users\przemek\AppData\Roaming\Composer\vendor\symfony\console\Application.php:192
 Symfony\Component\Console\Application->doRun() at C:\Users\przemek\AppData\Roaming\Composer\vendor\symfony\console\Application.php:123
 Symfony\Component\Console\Application->run() at C:\Users\przemek\AppData\Roaming\Composer\vendor\couscous\couscous\bin\couscous:43

Ok, nothing changed so nothing to commit - I could accept it (it was weird because I had still my old page). But I've tried and introduced simple change to one of MD files for documentation (which I'm keeping on /docs directory within project, see https://github.com/pnowy/NativeCriteria/tree/develop/docs).

In this case the generated structure reflect the project structure. This gh-pages branch should have on main directory the content of the .couscous/generated files. Without that I won't have updated page.

In this case I've started digging and take a look at generated temp directory and there the generated structure ok but for some reason is not copied to the gh-pages branch (there is copied a develop content).

So this moment I said - ok I will try from scratch. I've removed local and remote gh-pages branches and run the couscous deploy -v.

My console output:

Generating D:\projects\NativeCriteria to D:\projects\NativeCriteria/.couscous/generated
[notice] Fetching template from https://github.com/pnowy/CouscousNativeTemplate

Deploying the website
Cloning [email protected]:pnowy/NativeCriteria.git in C:\Users\przemek\AppData\Local\Temp\cou8CD8.tmp
Checking out branch gh-pages
Copying generated website
Committing changes


  [Couscous\CommandRunner\CommandException]
  On branch gh-pages
  nothing to commit, working directory clean


Exception trace:
 () at C:\Users\przemek\AppData\Roaming\Composer\vendor\couscous\couscous\src\CommandRunner\CommandRunner.php:29
 Couscous\CommandRunner\CommandRunner->run() at C:\Users\przemek\AppData\Roaming\Composer\vendor\couscous\couscous\src\CommandRunner\Git.php:61
 Couscous\CommandRunner\Git->run() at C:\Users\przemek\AppData\Roaming\Composer\vendor\couscous\couscous\src\CommandRunner\Git.php:39
 Couscous\CommandRunner\Git->commitAllChanges() at C:\Users\przemek\AppData\Roaming\Composer\vendor\couscous\couscous\src\Deployer.php:111
 Couscous\Deployer->commitChanges() at C:\Users\przemek\AppData\Roaming\Composer\vendor\couscous\couscous\src\Deployer.php:54
 Couscous\Deployer->deploy() at C:\Users\przemek\AppData\Roaming\Composer\vendor\couscous\couscous\src\Application\Cli\DeployCommand.php:110
 Couscous\Application\Cli\DeployCommand->execute() at C:\Users\przemek\AppData\Roaming\Composer\vendor\symfony\console\Command\Command.php:259
 Symfony\Component\Console\Command\Command->run() at C:\Users\przemek\AppData\Roaming\Composer\vendor\symfony\console\Application.php:844
 Symfony\Component\Console\Application->doRunCommand() at C:\Users\przemek\AppData\Roaming\Composer\vendor\symfony\console\Application.php:192
 Symfony\Component\Console\Application->doRun() at C:\Users\przemek\AppData\Roaming\Composer\vendor\symfony\console\Application.php:123
 Symfony\Component\Console\Application->run() at C:\Users\przemek\AppData\Roaming\Composer\vendor\couscous\couscous\bin\couscous:43

deploy [--repository REPOSITORY] [--branch BRANCH] [--] [<source>]

What is wrong here? The generated local branch gh-pages is identical with develop branch but the directory C:\Users\przemek\AppData\Local\Temp\cou8CD8.tmp contains correct content (the generated content when I'm invoking preview).

So I think the problem is that for some reason the tmp directory is not correctly copied to switched branch and there is a copied the original source-code branch. Could you check it?

PS. Is there a option to generate preview (I mean .couscous/generated directory content) with destination URL-s? I meant that I want to generate destination documentation for my project without deploy command and I want to copy it manually (but on normal preview there are localhost instead of my github page addresses and I don't want that).

Thanks,
Przemyslaw

@cyberbit
Copy link
Contributor

I can answer your PS. Use couscous generate to run the full generate script, stopping right before deployment. It will output with the proper links to .couscous/generated.

@mnapoli
Copy link
Member

mnapoli commented Jun 16, 2016

I know we had troubles before with Windows, see for example #135 which is still open (or also https://github.com/CouscousPHP/Couscous/pulls?q=is%3Apr+windows+is%3Aclosed), so it might be it (else I'm using the worflow you are trying every week - linux/mac - and I don't have any issue). Unfortunately I don't have a Windows machine to test Couscous at all on it.

@pnowy
Copy link
Contributor Author

pnowy commented Jun 17, 2016

Ok, on free time I will prepare ubuntu vm and check how this command work there. If there won't be a problem I will try debug the code on windows machine.

In meantime I will use couscous generate mentioned by @cyberbit and write my own script for deploy.

Did you notice mentioned problem with git pull of gh-pages branch? Are you planning fix for it?

@mnapoli
Copy link
Member

mnapoli commented Jun 17, 2016

Did you notice mentioned problem with git pull of gh-pages branch? Are you planning fix for it?

Right, I'm leaving on holidays tomorrow so feel free to send a pull request ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants