Showing posts with label english. Show all posts
Showing posts with label english. Show all posts

Saturday, February 23, 2013

Handling remote bare Git repository

When you have Git repositories as below.

  • CENTER.git : Central repository you can not manage
  • MAIN.git : Main repository that your team push into
  • LOCAL : Local repository on developers local machine

Merge on bare repository

You can't merge on bare repository such as MAIN.git because bare repository has no working copy. There are no ways to resolve the conflict when it occurs. Therefore, you must checkout the target branch into your local repository, merge your commits, then push to bare repository(MAIN.git).

Merge from external repository

Use 'git fetch' when there are some changes on CENTER.git. But this command doesn't update HEAD position. So you should use 'git reset --soft'.

# on MAIN.git
$ git fetch <CENTER.git>
$ git reset --soft HEAD
check commit histories using 'git log'.

Push specified branch

You can push local branch 'dev-local' into 'dev-remote' on origin.

$ git push origin dev-local:dev-remote

Clone from remote branch

You can checkout 'dev-remote' branch on MAIN.git into 'dev-local' branch on local machine:

git clone <MAIN.git>
git checkout -b dev-local remotes/origin/dev-remote

Push tags into remote repository

You can push local tags into remote repository.

$ git push --tags

This article is translated from Japanese.

Friday, February 22, 2013

How to create new environment type (RAILS_ENV) for Rails3

You know there are development, test and production environments on Ruby on Rails. This article shows you how to create new environment for your system.

We are currently working with:

  • Ruby: 1.9.2
  • Ruby on Rails: 3.0.5

How to refer environment name

You can refer environment name through Rails.env.

p Rails.env #=> "development"

Adding new environment

For example, you can add your new 'staging' environment by these steps. Follow these steps to add your new 'staging' environment.

  1. copy RAILS_HOME/config/environments/production.rb as RAILS_HOME/config/environmentsstaging.rb
  2. add staging section into database.yml
If you have any other configuration file, edit the configuration too.

Then, create database, do migration, and start your staging server.

$ rake db:create RAILS_ENV=staging
$ rake db:migrate RAILS_ENV=staging
$ rails server -e staging
Yes! You now have new 'staging' environment for your project.

gem setting

You can use different gems for your each environment. This situation, write your Gemfile as below.

group :development, :test do
  gem 'sqlite3-ruby'
end
group :staging, :production do
  gem 'mysql2', '0.2.7'
end
You can reject unnecessary gems for specified environment.
$ bundle install --without test development
see: Bundler : Using Groups

This article is translated from Japanese.

Wednesday, August 31, 2011

markd

markd is rich html builder for markdown, and is especially focused on printing purpose. You can get well-formatted printings (or PDF by preview) when you print html using modern browser (such as Google Chrome, Firefox, Safari).

Source code is available on github.

markd is based on bluecloth and google code prittify.

features:

  • Well-formatted HTML with CSS
  • Good style for printings
  • Auto numbered chapters
  • Code Highlighting

Installation

You can install markd using RubyGems as below:

$ gem install markd

Usage

Build html from markdown:

$ markd -o out_dir markdown.md
where markdown.md is target markdown file and out_dir is directory that html/css/js files are generated into.

Use -h (or --help) option to show detail.
$ markd -h

License

markd is released under the MIT license.

Enjoy!