{ "cells": [ { "cell_type": "markdown", "id": "cc2b57e5-9ba9-4146-bd85-963b561d3b87", "metadata": {}, "source": [ "# Sample Usage\n", "\n", "## Import semantic_branch Python Library" ] }, { "cell_type": "code", "execution_count": 29, "id": "cf1fdf52-a193-4539-a246-13d54a77f8af", "metadata": { "ExecuteTime": { "end_time": "2023-09-25T15:36:14.929877Z", "start_time": "2023-09-25T15:36:14.925278Z" } }, "outputs": [], "source": [ "import semantic_branch.api as semantic_branch" ] }, { "cell_type": "markdown", "id": "56a39e9d-17f8-4d88-9115-e6b9eff3caa3", "metadata": { "collapsed": false, "jupyter": { "outputs_hidden": false } }, "source": [ "## Validating Semantic Branch Names" ] }, { "cell_type": "code", "execution_count": 30, "id": "e61f8be8-3ff4-45f9-89cc-a96acd155cc7", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "True" ] }, "execution_count": 30, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# Check if a branch name is valid\n", "semantic_branch.is_valid_semantic_name(\"feature\")" ] }, { "cell_type": "code", "execution_count": 31, "id": "5c665f2b-51c1-4088-9aef-6b1ac5e44992", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "False" ] }, "execution_count": 31, "metadata": {}, "output_type": "execute_result" } ], "source": [ "semantic_branch.is_valid_semantic_name(\"Feature\")" ] }, { "cell_type": "markdown", "id": "dcb8778f-d482-4686-beca-1a5945b85cc3", "metadata": {}, "source": [ "## Detecting Branch Types" ] }, { "cell_type": "code", "execution_count": 32, "id": "db18e1ec-883f-4c27-97f2-b6438b7dfc33", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "True" ] }, "execution_count": 32, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# Check if a branch is a feature branch\n", "semantic_branch.is_certain_semantic_branch(\"feature/add-login\", stubs=[\"feat\", \"feature\"])" ] }, { "cell_type": "code", "execution_count": 33, "id": "0af7f003-96e7-44d3-b322-e551ac0fc181", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "False" ] }, "execution_count": 33, "metadata": {}, "output_type": "execute_result" } ], "source": [ "semantic_branch.is_certain_semantic_branch(\"main\", stubs=[\"feat\", \"feature\"])" ] }, { "cell_type": "markdown", "id": "2b14edbc-e089-4ed2-8669-47acbec855c7", "metadata": {}, "source": [ "## Using Semantic Branch Enums" ] }, { "cell_type": "code", "execution_count": 34, "id": "07c5c411-3686-4c9e-91de-17476093724c", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "SemanticBranch(name='feature', stubs=['feat', 'feature'])" ] }, "execution_count": 34, "metadata": {}, "output_type": "execute_result" } ], "source": [ "feature_branch = semantic_branch.SemanticBranchEnum.feature.value\n", "feature_branch" ] }, { "cell_type": "code", "execution_count": 35, "id": "779f7351-c2e4-40ea-a683-5d6004d10230", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "'feature'" ] }, "execution_count": 35, "metadata": {}, "output_type": "execute_result" } ], "source": [ "feature_branch.name" ] }, { "cell_type": "code", "execution_count": 36, "id": "c7f0c514-7fd4-43f7-8c27-3b8a3563596b", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "['feat', 'feature']" ] }, "execution_count": 36, "metadata": {}, "output_type": "execute_result" } ], "source": [ "feature_branch.stubs" ] }, { "cell_type": "code", "execution_count": 37, "id": "0bd49550-d597-42d5-b0d3-d6df7760b781", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "True" ] }, "execution_count": 37, "metadata": {}, "output_type": "execute_result" } ], "source": [ "feature_branch.is_match(\"feat-123\")" ] }, { "cell_type": "code", "execution_count": 38, "id": "fe89fa2b-d62a-49fb-9396-584530f482ec", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "False" ] }, "execution_count": 38, "metadata": {}, "output_type": "execute_result" } ], "source": [ "feature_branch.is_match(\"main\")" ] }, { "cell_type": "code", "execution_count": 39, "id": "90daec0d-7ab5-461b-a1eb-d4557c30196d", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "'feature'" ] }, "execution_count": 39, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# Access semantic stubs\n", "semantic_branch.SemanticStubEnum.feature.value" ] }, { "cell_type": "code", "execution_count": 40, "id": "0b8552d7-c301-4de3-bd02-36bb40f66ac7", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "'fix'" ] }, "execution_count": 40, "metadata": {}, "output_type": "execute_result" } ], "source": [ "semantic_branch.SemanticStubEnum.fix.value" ] }, { "cell_type": "code", "execution_count": null, "id": "7a049c9d-95ee-40b9-95c9-8a39491b3450", "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.11.8" } }, "nbformat": 4, "nbformat_minor": 5 }