简体   繁体   English

维护金字塔项目的定制版本(git分支,代码内变化或其他方法?)

[英]Maintaining customized versions of pyramid project (git branches, in-code variation, or other method?)

Introduction 介绍

I have a simple pyramid project for inventory management, and use git as my VCS. 我有一个用于库存管理的简单金字塔项目,并将git用作我的VCS。 Switching away from git would not be hard, but switching away from pyramid would be. 离开git并不难,但是离开金字塔则很困难。 The scope of the project is quite small, meant for use by a single organization, with maybe 5-20 logins max at a time. 该项目的范围很小,只能由一个组织使用,一次最多可以登录5-20次。 The project is developed for A. 该项目是为A开发的。

Problem statement 问题陈述

B also wants an inventory management software, and I wish to re-use what I've already developed for A. There are certain fundamental differences (most importantly, the item models would differ as both A and B are interested in different attributes) as well as view differences (at the very least the logo on the page would differ, and B probably wants different pages based on their usage pattern, much more focused on keeping track of item loans where A is much more focused on ensuring timely delivery of items when purchase orders are sent to external suppliers). B也想要一个库存管理软件,我希望重用我已经为A开发的软件。存在一些基本差异(最重要的是,由于A和B都对不同的属性感兴趣,因此商品模型会有所不同)以及视图差异(至少页面上的徽标会有所不同,B可能会根据其使用模式而希望使用不同的页面,更多地关注于跟踪项目借出,而A更加关注于确保及时交付项目当采购订单发送给外部供应商时)。

Example of fundamental differences 基本差异示例

Both A and B would have models named Item and Group (Child-Parent relationship). A和B都将具有名为Item和Group(子-父母关系)的模型。 However A would keep track of 5 attributes for Item (eg Brand, Part Number, Target Delivery Date, Actual Received Date, Description) while B would keep track of 4 attributes for Item (eg Identification Number, Description, Item type (consumable or re-usable), and Purchase Date). 但是,A会跟踪项目的5个属性(例如品牌,零件号,目标交货日期,实际接收日期,描述),而B会跟踪项目的4个属性(例如标识号,描述,项目类型(消耗品或可重复使用的物品) -可用)和购买日期)。

Alternatives considered 考虑的替代方案

Having multiple branches off a single base (or a single submodule with common code) seems tough to keep synchronized/merged, mostly because I don't seem to have much 'common code' in the sense of fixed directories or files which would not change at all between versions. 在单个基础上(或具有通用代码的单个子模块)有多个分支似乎很难保持同步/合并,主要是因为在固定目录或文件不会改变的意义上,我似乎没有太多“通用代码”在所有版本之间。

Based on this talk - always ship trunk taken from the accepted answer to Workflow for maintaining different versions of a webapp using git? 基于此讨论- 始终工作流从接受的Workflow答案中提取出来,以便使用git维护Web应用程序的不同版本吗? the recommendation is instead to maintain a single branch (trunk/master, obviously feature development is a separate branch) but version in-code with if/else checks on flags. 建议改为维护一个分支(主干/主分支,显然,功能开发是一个单独的分支),但在代码内进行版本化,并在标志上进行if / else检查。 However it seems more suited to multiple versions of the same web-app rather than two (slightly differing) web-apps as in my case. 但是,它似乎更适合于同一Web应用程序的多个版本,而不是像我这样的两个(略有不同)Web应用程序。

Which of the above (or other alternatives) would involve the least maintenance burden, assuming both A and B's requirements don't significantly branch away from each other (eg A requests that financial accounting be included, at which point I would actually just fork a separate project)? 假设A和B的要求没有明显的分歧(例如,A要求包括财务会计,那么我实际上只是叉一个),以上哪一个(或其他替代方案)所涉及的维护负担最少。单独的项目)?

I don't know Pyramid, but rather than using a VCS-oriented approach (ie. branches), what you probably want is a modular approach. 我不了解金字塔,但是您可能不希望使用面向VCS的方法(即分支),而是模块化的方法。 Something like this: 像这样:

siteA/
    templates/
    config/
    assets/
    tests/
siteB/
    templates/
    config/
    assets/
    tests/
modules/
    inventory/
    financial/
    image_gallery/

The details of each site are kept separate from each other. 每个站点的详细信息彼此分开。 They have their own templates, configuration, and assets (images, and whatnot) that describe how they behave and how they look. 它们具有自己的模板,配置和资产(图像等),它们描述了它们的行为和外观。

Bits of functionality are developed as configurable modules. 一些功能被开发为可配置模块。 This is your inventory system, your financial system, an image gallery... whatever. 这是您的库存系统,财务系统,图库……等等。

Then siteA and siteB can individually choose which modules they want to use, configure how they act, and how they look. 然后,siteA和siteB可以分别选择它们要使用的模块,配置它们的行为以及外观。

The main advantage is that the details of the sites are decoupled from each other, so you can cater to the whims of your individual customers without changing how the other behaves. 主要优势在于站点的详细信息彼此分离,因此您可以迎合单个客户的异想天开,而无需更改其他客户的行为。 Someone can work on siteA without worrying about breaking siteB. 有人可以在siteA上工作,而不必担心会破坏siteB。 Common functionality is put into the modules which have a more formal, documented interface. 通用功能被放入模块中,这些模块具有更正式的文档化界面。

The main disadvantage is that if A and B have a lot in common it can get redundant. 主要缺点是,如果A和B有很多共同点,则会变得多余。 There's various ways to mitigate that: push more common functionality into the modules, create shared templates, symlink to common templates and assets, improve the default configuration of modules, or even branches. 有多种方法可以减轻这种情况:将更多常用功能推入模块,创建共享模板,符号链接到常用模板和资产,改进模块的默认配置甚至分支。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM