Giter Site home page Giter Site logo

Comments (36)

YahnisElsts avatar YahnisElsts commented on May 23, 2024

There are no such plans at the moment. Not that there's anything wrong with the idea; I just don't have the time.

from plugin-update-checker.

flowdee avatar flowdee commented on May 23, 2024

thanks for the reply anyway!

from plugin-update-checker.

dpolyakov avatar dpolyakov commented on May 23, 2024

+1

from plugin-update-checker.

bilaltas avatar bilaltas commented on May 23, 2024

+1

from plugin-update-checker.

YahnisElsts avatar YahnisElsts commented on May 23, 2024

I might have a chance to add this sometime soon, so I'm looking for input. What's your typical workflow for releasing new plugin/theme versions on BitBucket? How would one go about finding the latest stable version? (Is it a branch, tag, or does BitBucket have something like GitHub's "releases"?)

from plugin-update-checker.

bilaltas avatar bilaltas commented on May 23, 2024

Great, many thanks in advance! Tags are used for that on Bitbucket.

from plugin-update-checker.

dpolyakov avatar dpolyakov commented on May 23, 2024

Usually i am adding new tag, like v2.1, and merging feature branch in the master branch.

from plugin-update-checker.

bilaltas avatar bilaltas commented on May 23, 2024

But you don't have to deal with tags. You just get "readme.txt" from master and parse it.
That's it.

from plugin-update-checker.

YahnisElsts avatar YahnisElsts commented on May 23, 2024

Thanks for the feedback. However, wouldn't you still have to deal with tags to generate download URLs and get the last update timestamp? Also, I suspect that some developers might leave out the "Stable tag" header from their readme.txt.

On an unrelated note, how about authentication? Do you use public repositories (so no auth necessary), or private repositories with username/password, app passwords, or something else?

from plugin-update-checker.

dpolyakov avatar dpolyakov commented on May 23, 2024

I use private repos

from plugin-update-checker.

bilaltas avatar bilaltas commented on May 23, 2024

No, you don't have to. The download url is always same as https://bitbucket.org/{your-user-name}/repo/get/master.zip. To get the last update timestamp, you use the last commit created time.

I'm using free private repositories on Bitbucket. (Most of the people uses it because of that.) So, you need to access BitBucket API with a key and secret which is generated on this link: https://bitbucket.org/account/user/{your-user-name}/api
But, I'm not sure how to get downloadable zip url with that key and secret for Wordpress.

These may help you:
https://confluence.atlassian.com/bitbucket/oauth-on-bitbucket-cloud-238027431.html
https://developer.atlassian.com/bitbucket/api/2/reference/resource/repositories/%7Busername%7D/%7Brepo_slug%7D/downloads#downloadsResource-GETaspecificfile

from plugin-update-checker.

YahnisElsts avatar YahnisElsts commented on May 23, 2024

@bilaltas Wait, so are you using tags or not? That download URL would point to the master branch, not a tag. Or are you implying that in your case master is always stable and identical to the latest tag?

from plugin-update-checker.

bilaltas avatar bilaltas commented on May 23, 2024

@YahnisElsts I'm using Bitbucket Tags but I don't have to. For me, it's just to show which commit is belong to which version of the plugin. Not everyone fills it, most of them do. Yes, in my case, master is always stable and identical to the latest tag. If I work on a beta version, I would create another branch.

https://bitbucket.org/{your-username}/{your-repo}/get/{your-latest-tag}.zip (Tags might be text or number or both)
and
https://bitbucket.org/{your-username}/{your-repo}/get/master.zip downloads the same.

from plugin-update-checker.

korndev avatar korndev commented on May 23, 2024

We're using Bitbucket and don't use tags much right now and all our repos are private. The master branch is always production ready. That said, I like to sometimes use a "beta" branch for beta releases on plugins for those that want bleeding edge. If you went the direction of tags though, it'd be more than welcomed in order to integrated with Bitbucket repos.

from plugin-update-checker.

YahnisElsts avatar YahnisElsts commented on May 23, 2024

I think the update checker could support a couple of different approaches like it already does for plugins hosted on GitHub. For example, it could do this (in priority order):

  1. Look at readme.txt in a specific branch. If it has a Stable tag header that points to a valid tag, use that tag.
  2. Look at the most recent tags, sort the ones that look like version numbers in descending order, and use the first tag.
  3. Just use the specified branch. The branch is configurable and defaults to master.

from plugin-update-checker.

dpolyakov avatar dpolyakov commented on May 23, 2024

Sounds like a plan :)

from plugin-update-checker.

bilaltas avatar bilaltas commented on May 23, 2024

About one year ago, I tried integrating Bitbucket api for your script but I haven't had time to complete. Last status of it has ability to check and detect the new version, but it cannot download and install it yet. I used Gentlero's Bitbucket PHP API Wrapper. I hope this files help you to complete it: (I'm not sure it still works, but it gives an idea.)

  • bitbucket-checker.php
  • plugin-update-checker.php

plugin-update-checker-with-bitbucket.zip

from plugin-update-checker.

YahnisElsts avatar YahnisElsts commented on May 23, 2024

I actually just got my own implementation to a sort-of-usable state. Anyone interested in testing BitBucket integration can find it in this branch:
https://github.com/YahnisElsts/plugin-update-checker/tree/theme-support

Usage:

$bitbucketPluginChecker = Puc_v4_Factory::buildUpdateChecker(
	'https://bitbucket.org/username/repository-name',
	__FILE__, //Full path to the main plugin file.
	'unique-plugin-slug' //Usually the same as your plugin directory name.
);

//If your repository is private, create an OAuth consumer that has read access
//to the repository and and set the credentials like this:
$bitbucketPluginChecker->setAuthentication(array(
	'consumer_key' => 'abc',
	'consumer_secret' => 'def',
));

Fair warning: This stuff is mostly untested and definitely not production-ready. It might just crash right away.

from plugin-update-checker.

bilaltas avatar bilaltas commented on May 23, 2024

Oh good! I didn't know you already started it. :)

from plugin-update-checker.

YahnisElsts avatar YahnisElsts commented on May 23, 2024

Update: Now BitBucket support should also work with themes. The setup is almost identical to plugins:

$bitbucketThemeChecker = Puc_v4_Factory::buildUpdateChecker(
	'https://bitbucket.org/username/repository-name',
	__FILE__, //Full path to your functions.php file.
	'unique-theme-slug' //Optional. Usually the same as your theme directory name.
);

The only significant difference is that the second parameter must be an absolute path to any file inside your theme's directory. If your update-related code is inside functions.php, the __FILE__ constant would be a good choice. The update checker uses this path to distinguish between plugins and themes and to get the theme slug.

from plugin-update-checker.

YahnisElsts avatar YahnisElsts commented on May 23, 2024

Update: Version 4.0 has been released and it includes BitBucket support.

from plugin-update-checker.

bilaltas avatar bilaltas commented on May 23, 2024

Thank you Yahnis. But I couldn't get it worked yet. Two problems I saw:

  1. Doesn't work with 3 digits version numbers

screen shot 2017-01-11 at 22 40 52

Shows v0.1 as the final version.
  1. If I change the installed plugin's version to 0.0, it shows an update. Once I start the update, it gives this error message:

screen shot 2017-01-11 at 22 44 12

from plugin-update-checker.

YahnisElsts avatar YahnisElsts commented on May 23, 2024

Thank you for the report. I could swear I tested the installation process multiple times...

Anyway, both of those issues should be fixed now.

from plugin-update-checker.

bilaltas avatar bilaltas commented on May 23, 2024

Hello Yahnis! Is there any update on these issues?

from plugin-update-checker.

YahnisElsts avatar YahnisElsts commented on May 23, 2024

As I said, those issues should be fixed now.

Edit: In case that phrasing was ambiguous (English isn't my first language), here's a clarification: I believe both of those problems are fixed in the master branch. I tested it and everything worked correctly. However, just because something works for me doesn't mean it will work for everyone, which is why I said "should be" instead of "are".

from plugin-update-checker.

bilaltas avatar bilaltas commented on May 23, 2024

Sorry, I misunderstood you. I think because it was so fast. :)
I tried once you replied, both wasn't working. Now, issue #1 is still exist. It still shows the v0.1 as the latest. And, when I update it, it updates to the v0.1 perfectly. So, issue #2 is fixed.

from plugin-update-checker.

YahnisElsts avatar YahnisElsts commented on May 23, 2024

Well, I can't reproduce the problem with version numbers. In my own tests, the update checker picks the correct version.

Are you sure that:

  1. You've got the latest changes from the master branch?
  2. The style.css in the v0.1.6 tag has the correct header, i.e. Version: 0.1.6?

from plugin-update-checker.

bilaltas avatar bilaltas commented on May 23, 2024
  1. Yes, I have only branch which is master one.
  2. Yes, it has correct version header: Version: 0.1.6 (without "v" letter)

Could it be about the "v0.1" version is two-digit or something like that? Did you have a chance to test it that way?

from plugin-update-checker.

YahnisElsts avatar YahnisElsts commented on May 23, 2024

That shouldn't matter. I've tested it with both two-digit and three-digit version numbers, with and without the v prefix.

Unfortunately, there's not much else I can do without seeing what exactly is going on in your setup. What I would suggest is this: take a look at the getLatestTag method in Puc/v4/Vcs/BitBucketApi.php. Try tracing it with a debugger or add some var_dump()'s statements to see what it's doing. Confirm that:

  1. $tags->values includes the v0.1.6 tag
  2. This tag is also the first entry in $versionTags.

Chances are, one of those will be false. Then we can move on from there.

from plugin-update-checker.

bilaltas avatar bilaltas commented on May 23, 2024

Interestingly, it shows all the versions up to v0.1, not more.

from plugin-update-checker.

bilaltas avatar bilaltas commented on May 23, 2024

Only first 10 versions.

from plugin-update-checker.

bilaltas avatar bilaltas commented on May 23, 2024

I think I got the problem. The results are paginated as 10 by 10. Once I print the $tags directly, it shows:
screen shot 2017-01-24 at 01 47 54

from plugin-update-checker.

bilaltas avatar bilaltas commented on May 23, 2024

Hello again,
I could not find any way to reverse the output on the api. So I tried detecting the last page and updated the api code. I've changed the getLatestTag method like this and the problem is solved:

public function getLatestTag() {
	$tags = $this->api('/refs/tags');
	if ( !isset($tags, $tags->values) || !is_array($tags->values) ) {
		return null;
	}

	$lastPage = floor($tags->size / $tags->pagelen) + 1;
	if ( $lastPage > 1 ) {
		$tags = $this->api('/refs/tags?page='.$lastPage);
	}

	//Filter and sort the list of tags.
	$versionTags = $this->sortTagsByVersion($tags->values);

	//Return the first result.
	if ( !empty($versionTags) ) {
		$tag = $versionTags[0];
		return new Puc_v4_Vcs_Reference(array(
			'name' => $tag->name,
			'version' => ltrim($tag->name, 'v'),
			'updated' => $tag->target->date,
			'downloadUrl' => $this->getDownloadUrl($tag->name),
		));
	}
	return null;
}

from plugin-update-checker.

YahnisElsts avatar YahnisElsts commented on May 23, 2024

It looks like you're right about the source of the bug. I had assumed BitBucket would return the most recent results first, but that's apparently not the case. I didn't catch this in my own testing because my repository didn't have enough tags to trigger pagination.

There is actually a way to sort query responses. The documentation is pretty short on details, but after some expermentation, I was able to find a way to sort tags by commit date. (sort=-target.date). Try the patch I just committed - it should fix the problem.

from plugin-update-checker.

bilaltas avatar bilaltas commented on May 23, 2024

Great job Yahnis, thank you. 👍

from plugin-update-checker.

YahnisElsts avatar YahnisElsts commented on May 23, 2024

All right, I'll close this now. If anyone finds any new BitBucket-related bugs, please open a new issue.

from plugin-update-checker.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.