Wanchai / FTPbucket

FTPbucket is a PHP script that enables you to sync your BitBucket or GitHub repository with any web-server
102 stars 22 forks source link

Rewrite to use only BitBucket v2.0 APIs #24

Closed d2roth closed 5 years ago

d2roth commented 5 years ago

Because BitBucket is deprecating API version 1.0 I have rewritten the BitBucket JSON script to work with their new API. I have done preliminary testing but I would like others to review it as well.

I started with a fresh file though did use many of the concepts and principles from the previous BBjson.php file.

For PowerShell here were my two test scripts to create commits:

# Multiple commits to one file
For ($i = 1; $i -lt 5; $i++){
  For ($x = 1; $x -lt 15; $x++){
    echo "other contents ${x}" >> "test-${i}.txt";
    git add -A;
    git commit -am "Committing file ${i}";
  }
}

and

# Multiple commits to multiple files
For ($i = 1; $i -lt 100; $i++){
  For ($x = 1; $x -lt 5; $x++){
    echo "other contents ${x}-${i}" >> "test-${x}-${i}.txt";
  }
  git add -A;
  git commit -am "Committing file ${i}";
}

If you find any issues or have questions I am open to modifying it. I am planning on using this where I work but improvements would be welcomed.

pankydcoder commented 5 years ago

@d2roth I just saw this pull request. I have raised the same https://github.com/Wanchai/FTPbucket/issues/25 i guess. Can you please confirm this if it will get resolved with the pull request? If yes, i am eagerly waiting for it to get merged to master.

d2roth commented 5 years ago

@pankydcoder, when I made this pull request I had tested everything locally. Since then work for bust so I haven't implement this yet. I did however run into the same issue with API version 1.0 being deprecated so I will try and implement this code in the next couple of days and respond here whether things work properly again.

pankydcoder commented 5 years ago

@d2roth Great. Thankyou!!

pankydcoder commented 5 years ago

Hi @d2roth , Did you get chance to work on this issue?

d2roth commented 5 years ago

Hey @pankydcoder , I am looking through this now and I realize I still used some 1.0 endpoints so this pull request will not fix the issue.

The new problem is that BitBucket no longer supports changesets so I think we would need to change to using diffstat and parse through it to find the files that were changed.

The API documentation for diffstat is here: https://developer.atlassian.com/bitbucket/api/2/reference/resource/repositories/%7Busername%7D/%7Brepo_slug%7D/diffstat/%7Bspec%7D

I will continue to look into this but it is looking fairly complicated to get the list of files that were changed between two commits.

d2roth commented 5 years ago

Hey @pankydcoder , I have been able to get the list of files with running diffstat. I still have more testing to do and to complete rewriting all of the methods but I think I can get this back up and working with BitBucket 2.0 APIs.

I will update here when I know more.

pankydcoder commented 5 years ago

@d2roth Glad to know that you got the way. Thanks a lot for all the efforts you are putting in to get this working.