jekyll-release 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,56 @@
1
+ #!/bin/bash
2
+ #
3
+ # git-commit-filetree - commit an arbitrary tree of files
4
+ # to a branch in a git repository.
5
+ #
6
+ # Version: cjsnjr.2015-08-08.0
7
+ #
8
+ # Authors:
9
+ # Curt J. Sampson <cjs@cynic.net>
10
+ # Nishant Rodrigues <nishantjr@gmail.com>
11
+ # Please find the latest version of this (with tests and copying rights) at:
12
+ # https://github.com/cjs-cynic-net/git-commit-filetree
13
+ #
14
+
15
+ set -e
16
+
17
+ index_file=$(mktemp)
18
+ internal_error=true
19
+ trap 'rm -f $index_file; $internal_error && err 255 "INTERNAL ERROR. FAILED!"' 0
20
+
21
+ err() {
22
+ local exitcode="$1"; shift
23
+ internal_error=false
24
+ echo 1>&2 "$@"
25
+ exit $exitcode
26
+ }
27
+
28
+ [ -z "$2" ] && err 129 "Usage: git commit-filetree <branch> <path>"
29
+
30
+ # Check that we have no uncommited or unknown files.
31
+ git diff-index --quiet HEAD \
32
+ || err 1 "Cannot commit with uncommited files in working copy."
33
+ [ -z "$(git ls-files --exclude-standard --others)" ] \
34
+ || err 1 "Cannot commit with untracked files in working copy."
35
+
36
+ branch=refs/heads/$(echo $1 | sed -e 's,^refs/heads/,,')
37
+ git show-ref -q --verify $branch || err 128 "Invalid ref: $branch"
38
+
39
+ source_sha=$(git show --quiet --pretty='format:%h')
40
+
41
+ # Switch to an index separate from repo working copy.
42
+ export GIT_INDEX_FILE=$index_file
43
+
44
+ git read-tree --empty
45
+ git --work-tree=$2 add -A
46
+ tree_sha=$(git write-tree)
47
+ parent_tree_sha=$(git log -1 $branch --format='%T')
48
+ [ "$tree_sha" = "$parent_tree_sha" ] && { internal_error=false; exit 0; }
49
+
50
+ commit_msg="Build from source commit $source_sha."
51
+ commit_sha=$(echo "$commit_msg" | git commit-tree $tree_sha -p $branch)
52
+
53
+ git update-ref $branch $commit_sha \
54
+ -m "commit-filetree: $commit_msg"
55
+
56
+ internal_error=false
@@ -0,0 +1,22 @@
1
+ class ReleaseCommand < Jekyll::Command
2
+ class << self
3
+ def init_with_program(prog)
4
+ prog.command(:release) { |c|
5
+ c.syntax "release"
6
+ c.description 'Release current build to gh-pages branch.'
7
+ c.action { |args, options|
8
+ build_options = options.dup
9
+ build_options['quiet'] = true
10
+ Jekyll::Commands::Build.process(build_options)
11
+ process(options)
12
+ }
13
+ }
14
+ end
15
+
16
+ def process(options)
17
+ dest = configuration_from_options(options)['destination']
18
+ system(Gem.bin_path('jekyll-release', 'git-commit-filetree'), 'gh-pages', dest) \
19
+ || fail('git-commit-filetree failed.')
20
+ end
21
+ end
22
+ end
metadata ADDED
@@ -0,0 +1,51 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: jekyll-release
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Nishant Rodrigues
9
+ - Curt Sampson
10
+ autorequire:
11
+ bindir: bin
12
+ cert_chain: []
13
+ date: 2015-10-11 00:00:00.000000000 Z
14
+ dependencies: []
15
+ description: A Jekyll plugin that provides a 'release' command for jekyll that commits
16
+ the generated site to the 'gh-pages' branch of the git repository. This makes it
17
+ possible to commit the build without using multiple checkouts or switching branches
18
+ and moving files around.
19
+ email: nishantjr@gmail.com
20
+ executables:
21
+ - git-commit-filetree
22
+ extensions: []
23
+ extra_rdoc_files: []
24
+ files:
25
+ - lib/jekyll-release.rb
26
+ - bin/git-commit-filetree
27
+ homepage: http://github.com/cjs-cynic-net/git-commit-filetree
28
+ licenses: []
29
+ post_install_message:
30
+ rdoc_options: []
31
+ require_paths:
32
+ - lib
33
+ required_ruby_version: !ruby/object:Gem::Requirement
34
+ none: false
35
+ requirements:
36
+ - - ! '>='
37
+ - !ruby/object:Gem::Version
38
+ version: '0'
39
+ required_rubygems_version: !ruby/object:Gem::Requirement
40
+ none: false
41
+ requirements:
42
+ - - ! '>='
43
+ - !ruby/object:Gem::Version
44
+ version: '0'
45
+ requirements: []
46
+ rubyforge_project:
47
+ rubygems_version: 1.8.23
48
+ signing_key:
49
+ specification_version: 3
50
+ summary: Release Jekyll-generated websites to a git branch in a single command.
51
+ test_files: []