Skip to content

Commit 8ac0646

Browse files
authored
Merge branch 'master' into kpaulisse-validate-references
2 parents 8517eeb + 76bb22b commit 8ac0646

6 files changed

Lines changed: 118 additions & 1 deletion

File tree

doc/dev/run-from-branch.md

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# Running octocatalog-diff from a branch
2+
3+
When we are assisting with troubleshooting, or implementing a feature you've requested, we may ask you to run `octocatalog-diff` from a non-master branch to try it out.
4+
5+
This document is intended for people who may not be familiar with git, GitHub, and/or ruby. If you already know how to do this in another way, feel free!
6+
7+
## Installation
8+
9+
1. Determine the branch name. If there's an open Pull Request, you can see the branch name near the top of the page.
10+
11+
![Pull Request branch](/doc/images/pull-request-identify-branch.png)
12+
13+
2. Clone the `octocatalog-diff` repository in your home directory. From the command line:
14+
15+
```
16+
cd $HOME
17+
git clone https://github.com/github/octocatalog-diff.git
18+
```
19+
20+
3. Change into the directory created by your checkout:
21+
22+
```
23+
cd $HOME/octocatalog-diff
24+
```
25+
26+
4. Check out the branch you wish to use, filling in the branch name you determined in the first step:
27+
28+
```
29+
git checkout BRANCH_NAME_FROM_STEP_1
30+
```
31+
32+
5. Bootstrap the repository to pull in dependencies:
33+
34+
```
35+
./script/bootstrap
36+
```
37+
38+
6. Optional but recommended - run the test suite:
39+
40+
```
41+
rake
42+
```
43+
44+
## Use
45+
46+
Now that you have `octocatalog-diff` checked out and bootstrapped, it's time to use it.
47+
48+
We've created a wrapper script to make this easier for you.
49+
50+
1. Change directories to the location where you ordinarily run `octocatalog-diff` (for example: in your Puppet repository).
51+
52+
```
53+
cd /etc/puppetlabs/code
54+
```
55+
56+
2. Run the `script/octocatalog-diff-wrapper` script from *this* checkout. For example, if you checked out `octocatalog-diff` to your home directory, you could use:
57+
58+
```
59+
$HOME/octocatalog-diff/script/octocatalog-diff-wrapper <options>
60+
```
61+
62+
:warning: Note: If you are requesting our help, please use the debug option (`-d`) to display debugging information.
75.6 KB
Loading

doc/installation.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,9 @@ To install from source, you'll need a git client and internet access.
4747
Note: If tests fail on your machine with a clean checkout of the master branch, we would definitely appreciate if you would report it. Please [open an issue](https://github.com/github/octocatalog-diff/issues/new) with the output and some information about your system (e.g. OS, ruby version, etc.) to let us know.
4848

4949
Once the code is downloaded and bootstrapped, please proceed to [Configuration](/doc/configuration.md).
50+
51+
## Running from an alternate branch
52+
53+
We have prepared specific instructions for running `octocatalog-diff` from a non-master branch, for testing changes that may be requested by the developers.
54+
55+
- [Running octocatalog-diff from a branch](/doc/dev/run-from-branch.md)

lib/octocatalog-diff/catalog-diff/cli.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,8 @@ def self.setup_logger(logger, options, argv_save)
166166
logger.level = Logger::ERROR if options[:quiet]
167167

168168
# Some debugging information up front
169-
logger.debug "Running octocatalog-diff #{VERSION} with ruby #{RUBY_VERSION}"
169+
version_display = ENV['OCTOCATALOG_DIFF_CUSTOM_VERSION'] || VERSION
170+
logger.debug "Running octocatalog-diff #{version_display} with ruby #{RUBY_VERSION}"
170171
logger.debug "Command line arguments: #{argv_save.inspect}"
171172
logger.debug "Running on host #{Socket.gethostname} (#{RUBY_PLATFORM})"
172173
end

script/octocatalog-diff-wrapper

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/bin/bash
2+
3+
# This script exists to make it easier to test alternate branches of octocatalog-diff.
4+
# It is intended as a one-for-one replacement of `octocatalog-diff` as installed by the gem.
5+
6+
CURRENT_PWD="$(pwd)"
7+
CHECKOUT_BASE="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && cd .. && pwd )"
8+
9+
if [ -z "$OCTOCATALOG_DIFF_CONFIG_FILE" ]; then
10+
if [ -f "${CURRENT_PWD}/.octocatalog-diff.cfg.rb" ]; then
11+
export OCTOCATALOG_DIFF_CONFIG_FILE="${CURRENT_PWD}/.octocatalog-diff.cfg.rb"
12+
fi
13+
fi
14+
15+
cd "$CHECKOUT_BASE"
16+
export OCTOCATALOG_DIFF_CUSTOM_VERSION="@$(git rev-parse HEAD)"
17+
bundle exec bin/octocatalog-diff --basedir "$CURRENT_PWD" $*

spec/octocatalog-diff/tests/catalog-diff/cli_spec.rb

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,37 @@
115115
end
116116
end
117117

118+
describe '#setup_logger' do
119+
context 'with custom version specified in environment' do
120+
before(:each) do
121+
ENV['OCTOCATALOG_DIFF_CUSTOM_VERSION'] = '@d05c30152c897219367d586414ccb1f651ab7221'
122+
end
123+
124+
after(:each) do
125+
ENV.delete 'OCTOCATALOG_DIFF_CUSTOM_VERSION'
126+
end
127+
128+
it 'should log custom version' do
129+
logger, logger_str = OctocatalogDiff::Spec.setup_logger
130+
described_class.setup_logger(logger, { debug: true }, nil)
131+
expect(logger_str.string).to match(/Running octocatalog-diff @d05c30152c897219367d586414ccb1f651ab7221 with ruby/)
132+
end
133+
end
134+
135+
context 'with default version' do
136+
before(:each) do
137+
ENV.delete 'OCTOCATALOG_DIFF_CUSTOM_VERSION'
138+
end
139+
140+
it 'should log current version' do
141+
logger, logger_str = OctocatalogDiff::Spec.setup_logger
142+
described_class.setup_logger(logger, { debug: true }, nil)
143+
version = described_class::VERSION
144+
expect(logger_str.string).to match(/Running octocatalog-diff #{version} with ruby/)
145+
end
146+
end
147+
end
148+
118149
describe '#setup_fact_overrides' do
119150
it 'should make no adjustments when there are no fact overrides' do
120151
options = {}

0 commit comments

Comments
 (0)