commit e8c9f95156e35909e3aa8a87bb11d635224a9298 Author: Pavel Shevaev Date: Mon Oct 23 15:13:23 2023 +0300 Initial commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..6e92f57 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +tags diff --git a/composer.json b/composer.json new file mode 100644 index 0000000..fa8ff44 --- /dev/null +++ b/composer.json @@ -0,0 +1,11 @@ +{ + "name": "bit/taskman_git", + "description": "taskman git utils", + "homepage": "https://git.bit5.ru/composer/taskman_git", + "require": { + "php": ">=7.4" + }, + "autoload": { + "classmap": ["git.inc.php"] + } +} diff --git a/git.inc.php b/git.inc.php new file mode 100644 index 0000000..3eb8225 --- /dev/null +++ b/git.inc.php @@ -0,0 +1,118 @@ +major = (int)$parts[0]; + $v->minor = (int)$parts[1]; + $v->patch = (int)$parts[2]; + return $v; + } + + function bump($up_mode) + { + if($up_mode == 1) + ++$this->patch; + else if($up_mode == 2) + { + ++$this->minor; + $this->patch = 0; + } + else if($up_mode == 3) + { + ++$this->major; + $this->minor = 0; + $this->patch = 0; + } + else + throw new Exception("Unsupported up mode: $up_mode"); + } + + function encode() + { + return 'v'.$this->major.'.'.$this->minor.'.'.$this->patch; + } +}