From e8c9f95156e35909e3aa8a87bb11d635224a9298 Mon Sep 17 00:00:00 2001 From: Pavel Shevaev Date: Mon, 23 Oct 2023 15:13:23 +0300 Subject: [PATCH] Initial commit --- .gitignore | 1 + composer.json | 11 +++++ git.inc.php | 118 ++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 130 insertions(+) create mode 100644 .gitignore create mode 100644 composer.json create mode 100644 git.inc.php 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; + } +}