derhasi/staging

一个辅助脚本来将一个分支的确切代码状态部署到远程分支。

维护者

详细信息

github.com/derhasi/staging

源码

问题

安装次数: 10,318

依赖者: 0

建议者: 0

安全: 0

星标: 3

关注者: 2

分支: 0

开放问题: 0

语言:Shell

类型:bash-script

1.1.1 2015-06-26 08:05 UTC

This package is not auto-updated.

Last update: 2024-09-14 16:39:51 UTC


README

travis ci test status

一个辅助脚本来从一个 git 仓库部署特定的代码状态到另一个 git 仓库。

用于将指定分支的确切状态部署到远程分支的 Bash 脚本。这是通过使用 "diff commits" 来实现的。

此脚本用于将预演分支调整到特定分支的内容。生成的分支可能不会与给定分支共享历史记录,但会确保所有文件都处于与原始分支相同的状态。

需要此方法以确保我们可以使用具有固定分支的基于 git 的托管服务,以部署和测试多个不同的分支。在这种情况下,我们只有一个预演分支可以部署到。该分支只会接收到 "diff commits",这些提交将文件状态更改为给定分支定义的状态。

安装

通过 composer

composer global require derhasi/staging

手动

curl -O https://raw.githubusercontent.com/derhasi/staging/master/staging
chmod u+x staging
mv staging /usr/local/bin/staging
```

## Usage:

The command creates a commit on the `remoteBranch` with the exact code state of the `sourceBranch`.

```
staging [-hv] [-m "..."] {remote} {remoteBranch} {sourceBranch}"
```

In _local branch mode_ the state is applied on a local branch without pushing to a remote repository.

```
staging -l [-hv] [-m "..."] {localBranch} {sourceBranch}"
```


### Arguments

1. `{remote}`: Name of the remote repository to push the code to. Example: `origin`
2. `{remoteBranch}`: Name of the remote branch to push the code to. Example: `master`
3. `{sourceBranch}`: Name of the branch to get the code from. May be a local or a remote branch reference.
   Examples: `mybranch` or `origin/66-hello`

### Options

* `-h`: Shows help message for the command
* `-v`: Provides verbose output
* `-m "Custom commit message"`: Replaces the default message (`Staging: [source branch] (sha: [source sha])`) with the
  given custom one
* `-l`: Enables _local branch mode_

### Features

* Stashes the current uncommited changes of the current branch, and switches back to that state, after deploying the
  commit diff.
  
## Example

You have one stage environment available, where you are only allowed to push code via git. The corresponding git
repository is located at `https://stage.example.com/site.git`. The branch to deploy to is `master`. 
Now, you have got several branches in development (`123-story`, `124-event`, `125-contact`) you want to test on that
staging environment. You can do that, one after another using _staging_.

First, add your stage remote to your local repo: `git remote add stage https://stage.example.com/site.git`.

Now you can deploy the code to your stage from any arbitrary branch.

Let's start with the first: `staging stage master 123-story`.
After that `git diff 123-story stage/master` would show no difference.

With executing `staging stage master 124-event`, you will get the same for `git diff 123-story stage/master`.

You even can enter `staging stage master origin/125-contact` to directly work with the a remote branch instead of a
local branch.