requarks / wiki-v1

Legacy version (1.x) of Wiki.js
https://wiki.js.org
GNU Affero General Public License v3.0
100 stars 75 forks source link

cannot push on remote branch #22

Open savoisn opened 7 years ago

savoisn commented 7 years ago

Actual behavior

While using docker to test on my documentation repo I've got everything running on a branch called nsa-wikijs except the page edition When I edit a page from within the application, it edits ok in the app, but the code is not pushed back on the remote branch. I have this error :

wikijs_1  | 2017-08-28T14:15:01.543Z - info: [AGENT] Git Pull completed.
wikijs_1  | 2017-08-28T14:15:01.554Z - info: [AGENT] Performing push to remote Git repository...
wikijs_1  | 2017-08-28T14:15:01.563Z - error: [AGENT] Unable to push changes to remote Git repository!
wikijs_1  | 2017-08-28T14:15:01.563Z - error: [AGENT] One or more jobs have failed:
wikijs_1  | { code: 1,
wikijs_1  |   message: '`git --git-dir=repo/.git --work-tree=repo push origin nsa-wikijs` failed with code 1',
wikijs_1  |   stderr: 'error: src refspec nsa-wikijs does not match any.\nerror: failed to push some refs to \'git@github.com:theodo/fastit-documentation.git\'\n',
wikijs_1  |   stdout: '' }

btw it's working perfectly on master.

Expected behavior

The remote repo is updated on the changes done on the app.

Steps to reproduce the behavior

configure wikijs to a repo containing markdown documentation on a branch different than the master for example :

you can check my test repo here : https://github.com/savoisn/wikijs-test extract from my config.yml

git:
  url: git@github.com:savoisn/wikijs-docs.git
  branch: nsa-wikijs
  auth:

    # Type: basic or ssh
    type: ssh

docker-compose up http://localhost:3000/ login with the admin user make a change in the webapp and check the log you should see the error reported above.

p.s. I've just pull the new docker image as of today (2017-08-28) :)

NGPixel commented 7 years ago

Is your repo initialized?

savoisn commented 7 years ago

Yes, the repo is initialized and the content is even index based on the right branch.

NSA

Le 28 août 2017 7:08 PM, "Nicolas Giard" notifications@github.com a écrit :

Is your repo initialized?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/Requarks/wiki/issues/227#issuecomment-325414187, or mute the thread https://github.com/notifications/unsubscribe-auth/AAjMXclnnAxdTqp-FivJW3ZFn2IYeMbOks5scvQZgaJpZM4PEnym .

eburgueno commented 7 years ago

I have the same issue. I believe this is because the wrong branch name is being used:

2017-09-07T03:40:02.968Z - error: [AGENT] Unable to push changes to remote Git repository!
2017-09-07T03:40:02.969Z - error: [AGENT] One or more jobs have failed:  
{ code: 1,
  message: '`git --git-dir=repo/.git --work-tree=repo push origin wiki` failed with code 1',
  stderr: 'error: src refspec wiki does not match any.\nerror: failed to push some refs to \'git@github.com:myorganisation/myrepo.git\'\n',
  stdout: '' }

# docker exec -ti wikijs_wikijs_1 bash
bash-4.3# cd repo/                                                                                                                                                                                                
bash-4.3# git push origin wiki
error: src refspec wiki does not match any.
error: failed to push some refs to 'git@github.com:myorganisation/myrepo.git'
bash-4.3# git branch
* master
NGPixel commented 7 years ago

This is a bug, as the local branch isn't set before pushing to the remote branch. Use the master branch for now.

eburgueno commented 7 years ago

Yes. The other workaround is to manually set the local branch name with git branch -m <branch name> in the ./repo directory.

Bamieh commented 7 years ago

I faced the same issue. it happens when the repo is initialized at master branch, but the config informs it to push on another (wiki in this case). I had to fetch and checkout to that branch manually. The fix would be having the code checkout to the specified branch on initialization.

b-douglas commented 6 years ago

HEY I KNOW How to fix this...

@NGPixel

You just have to change this line here:


index 0766d69..a331f25 100644
--- a/server/configure.js
+++ b/server/configure.js
@@ -243,7 +243,7 @@ module.exports = (port, spinner) => {
       },
       () => {
         if (req.body.gitUseRemote === false) { return false }
-        return exec.stdout('git', ['pull', 'origin', req.body.gitBranch], { cwd: gitDir }).then(result => {
+        return exec.stdout('git', ['pull', 'origin', req.body.gitBranch + ':' + req.body.gitBranch], { cwd: gitDir }).then(result => {
           return 'Git Pull operation successful.'
         })
       }```

All you have to do is do a git pull origin branchname:branchname

The ':' will pull branch into branch.

And this *won't* break your existing master branch code.
b-douglas commented 6 years ago

I created a patch file to apply based on current dev branch.

Here ya go:

0001-227-cannot-push-on-remote-branch-updating-server-set.patch.txt