Skip to content

Commit 6003fea

Browse files
authored
Merge pull request #105 from blackducksoftware/OTWO-5545
Fix hg(v4) use & upgrade TravisCI to ubuntu 18.04
2 parents ec20fa5 + 3e89a32 commit 6003fea

18 files changed

+111
-79
lines changed

.travis.yml

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,6 @@
1-
language: ruby
2-
env:
3-
- TRAVIS_CONFIG_DIR=.travis
1+
language: generic
2+
services:
3+
- docker
44
before_install:
5-
- cd $TRAVIS_CONFIG_DIR
6-
- sh .travis_ssh_setup.sh
7-
install:
8-
- sh .install_multiple_scms.sh
9-
- sh .install_dependencies.sh
10-
- gem install posix-spawn
11-
- gem install nokogiri -v 1.8.1
12-
- gem install test-unit -v 3.2.7
13-
- sudo apt-get install expect
14-
before_script:
15-
- cd $TRAVIS_BUILD_DIR
5+
- docker pull notalex/ohloh_scm:ubuntu18
6+
script: docker run -P -w /home/app/ohloh_scm -v $(pwd):/home/app/ohloh_scm -ti notalex/ohloh_scm:ubuntu18 /bin/sh -c "/etc/init.d/ssh start; LANG=en_US.UTF-8 rake test 2> /dev/null"

.travis/.install_dependencies.sh

Lines changed: 0 additions & 15 deletions
This file was deleted.

.travis/.install_multiple_scms.sh

Lines changed: 0 additions & 6 deletions
This file was deleted.

.travis/.travis_ssh_setup.sh

Lines changed: 0 additions & 3 deletions
This file was deleted.

Dockerfile

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
FROM ubuntu:18.04
2+
MAINTAINER OpenHub <info@openhub.net>
3+
4+
ENV DEBIAN_FRONTEND=noninteractive
5+
6+
RUN apt-get update
7+
RUN apt-get install -y build-essential software-properties-common locales
8+
RUN locale-gen en_US.UTF-8
9+
10+
RUN apt-add-repository -y ppa:brightbox/ruby-ng
11+
RUN apt-get update
12+
RUN apt-get install -y ruby2.3 ruby2.3-dev
13+
14+
RUN apt-get install -y ragel libxml2-dev libpcre3 libpcre3-dev swig gperf openssh-server expect
15+
RUN apt-get install -y git git-svn subversion cvs mercurial bzr
16+
17+
RUN ssh-keygen -q -t rsa -N '' -f /root/.ssh/id_rsa
18+
RUN cp ~/.ssh/id_rsa.pub ~/.ssh/authorized_keys
19+
RUN echo 'StrictHostKeyChecking no' >> ~/.ssh/config
20+
21+
RUN mkdir -p ~/.bazaar/plugins
22+
RUN cd ~/.bazaar/plugins
23+
RUN bzr branch lp:bzr-xmloutput ~/.bazaar/plugins/xmloutput
24+
25+
RUN ln -s /usr/bin/cvs /usr/bin/cvsnt
26+
27+
RUN gem install posix-spawn -v '~> 0.3'
28+
RUN gem install nokogiri -v '~> 1.8'
29+
RUN gem install rake test-unit byebug
30+
31+
RUN mkdir -p /home/app/ohloh_scm

README.md

Lines changed: 44 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
[![Ohloh SCM on Ohloh](https://www.ohloh.net/p/ohloh_scm/widgets/project_partner_badge.gif)](https://www.ohloh.net/p/ohloh_scm) [![Build Status](https://travis-ci.org/blackducksoftware/ohloh_scm.svg?branch=master)](https://travis-ci.org/blackducksoftware/ohloh_scm)
1+
[![Ohloh SCM on OpenHub](https://www.openhub.net/p/ohloh_scm/widgets/project_partner_badge.gif)](https://www.openhub.net/p/ohloh_scm) [![Build Status](https://travis-ci.org/blackducksoftware/ohloh_scm.svg?branch=master)](https://travis-ci.org/blackducksoftware/ohloh_scm)
22

33
# Ohloh SCM
44

5-
The Ohloh source control management library
5+
The OpenHub source control management library
66

77
This program is free software; you can redistribute it and/or modify
88
it under the terms of the GNU General Public License Version 2 as
@@ -24,27 +24,30 @@ Ohloh SCM is an abstraction layer for source control management systems,
2424
allowing an application to interoperate with various SCMs using a
2525
single interface.
2626

27-
It was originally developed at Ohloh, and is used to generate
28-
the reports at www.ohloh.net.
27+
It was originally developed at OpenHub, and is used to generate
28+
the reports at www.openhub.net.
2929

3030
## System Requirements
3131

32-
Ohloh SCM is developed on Mac OS X 10.5 and Ubuntu 6.06 LTS. Other Linux
33-
environments should also work, but your mileage may vary.
32+
One could use the bundled Dockerfile to test Ohloh SCM in a container and skip
33+
this section entirely. See [docker](https://github.com/blackducksoftware/ohloh_scm/#using-docker).
34+
35+
Ohloh SCM is developed on Mac OS X 10.13.6(High Sierra) and Ubuntu 18.04 LTS.
36+
Other Linux environments should also work, but your mileage may vary.
3437

3538
Ohloh SCM does not support Windows.
3639

37-
Ohloh SCM targets Ruby 1.8.6 and Rake 0.8.1
40+
Ohloh SCM targets Ruby 2.3 and Rake 12.3.
3841

3942
Ohloh SCM interfaces with CVSNT, Subversion, Git and Mercurial through the
40-
shell. In order to pass the unit tests, all three systems must be installed
41-
and on your path. Ohloh uses the following versions, and other versions are
42-
totally unsupported at this time:
43+
shell. In order to pass the unit tests, all three systems must be installed
44+
and on your path. Ohloh is currently tested on the following versions:
4345

44-
cvsnt 2.5.03
45-
svn 1.4.2
46-
git 1.8.2.1
47-
hg 1.1.2
46+
cvsnt 2.5.03
47+
svn 1.9.7
48+
git 2.17.1
49+
hg 4.5.3
50+
bzr 2.8.0
4851

4952
If you are using CVS instead of CVSNT, you can potentially try creating
5053
a shell alias or symlink mapping 'cvsnt' to 'cvs'.
@@ -72,7 +75,7 @@ Ensure that cvsnt, svn, svnadmin, svnsync, git, and hg are all on your path. You
7275
$ mkdir plugins
7376
$ cd plugins
7477

75-
Now checkout the latest version of the xmloutput plugin (0.8.8 as of 11/21/2011).
78+
Now checkout the latest version of the xmloutput plugin (0.8.8 as of 11/21/2011).
7679

7780
$ bzr branch lp:~amujumdar/bzr-xmloutput/emit_authors
7881

@@ -97,9 +100,28 @@ Then you can run the unit tests:
97100

98101
You can load the library into your own Ruby application by requiring lib/ohloh_scm.rb.
99102

103+
## Using Docker
104+
105+
One may use Docker to run Ohloh SCM and test changes.
106+
107+
```sh
108+
$ git clone https://github.com/blackducksoftware/ohloh_scm
109+
$ cd ohloh_scm
110+
111+
# To run all tests, we need to start the ssh server and set UTF-8 locale for encoding tests.
112+
$ cmd='/etc/init.d/ssh start; LANG=en_US.UTF-8 rake test 2> /dev/null'
113+
$ docker run -P -w /home/app/ohloh_scm -v $(pwd):/home/app/ohloh_scm -ti notalex/ohloh_scm:ubuntu18 /bin/sh -c "$cmd"
114+
# This mounts the current folder into the docker container;
115+
# hence any edits made in ohloh_scm on the host machine would reflect in the container.
116+
117+
# One may also edit the Dockerfile & build the image locally for other distros.
118+
$ docker build -t ohloh_scm:custom .
119+
$ docker run -ti ohloh_scm:custom -v $(pwd):/home/app/ohloh_scm /bin/bash
120+
```
121+
100122
# Functionality
101123

102-
For each tracked repository, Ohloh uses the SCM library to maintain a private
124+
For each tracked repository, OpenHub uses the SCM library to maintain a private
103125
local mirror. The SCM library hides the differences between source control
104126
systems. The SCM library manages all required updates to a mirror, and reports
105127
the contents of the mirror in standardized ways.
@@ -109,15 +131,15 @@ store any content it desires in that directory. Usually, it's a direct clone of
109131
the original repository, but in the case of CVS or some Subversion servers, it
110132
is a conversion of the original repository to Git.
111133

112-
The main Ohloh application orchestrates the scheduling of all updates and
134+
The main OpenHub application orchestrates the scheduling of all updates and
113135
backups. On demand, the SCM library adapter then performs the following basic
114136
tasks on the local mirror:
115137

116138
1. Pull changes -- From a remote repository URL, pull any changes to the local
117139
mirror. This step may involve conversion from one system to another.
118-
2. Push changes -- From the local mirror, push any changes to another Ohloh
140+
2. Push changes -- From the local mirror, push any changes to another OpenHub
119141
server. This is required to create backup copies and perform load balancing on
120-
the Ohloh cluster, and typically occurs over ssh.
142+
the OpenHub cluster, and typically occurs over ssh.
121143
3. Commit log -- Given the last known commit, report the list of new commits,
122144
if any, including their diffs.
123145
4. Cat file or parent -- Given a commit, return either the contents of a
@@ -128,10 +150,7 @@ to a specified temp directory.
128150
The adapter must also implement validation routines used to filter user inputs
129151
and confirm the presence of the remote server.
130152

131-
# Contact Ohloh
132-
133-
For more information visit the Ohloh website:
134-
[Ohloh Labs](http://labs.ohloh.net)
153+
# Contact OpenHub
135154

136-
You can reach Ohloh via email at:
137-
[info@ohloh.net](mailto:info@ohloh.net)
155+
You can reach OpenHub via email at:
156+
[info@openhub.net](mailto:info@openhub.net)

Rakefile

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,8 @@ Gem::PackageTask.new(spec) do |pkg|
2626
pkg.need_zip = true
2727
end
2828

29-
Rake::TestTask.new :unit_tests do |t|
29+
Rake::TestTask.new :test do |t|
3030
t.test_files = FileList[File.dirname(__FILE__) + '/test/unit/**/*_test.rb']
3131
end
3232

33-
task :default => :unit_tests
34-
33+
task :default => :test

lib/ohloh_scm/adapters/hg/commits.rb

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ def commit_tokens(opts={})
1414
# Basically, we're trying very hard to make this act just like Git. The hg_rev_list_test checks this.
1515
tokens = run("cd '#{self.url}' && #{ hg_log_with_opts } --template='{node}\\n'").split("\n").reverse
1616

17+
# Since hg v4, --follow-first does not play well with -r N:n. Using them together always returns all commits.
18+
# To find trunk commits since a given revision, we get all trunk commits and drop older commits before given revision.
19+
tokens = tokens.drop(tokens.index(after)) if tokens.any? && after && after != 0
20+
1721
# Hg returns everything after *and including* after.
1822
# We want to exclude it.
1923
if tokens.any? && tokens.first == after
@@ -96,13 +100,13 @@ def hg_command_builder(opts)
96100
up_to = opts[:up_to] || :tip
97101

98102
options = if opts[:trunk_only]
99-
"--follow-first -r #{ up_to }:#{ after }"
103+
'--follow-first'
100104
else
101-
query = "and (branch(#{ branch_name }) or ancestors(#{ branch_name }))" if branch_name && branch_name != 'default'
105+
query = "and (branch(#{ branch_name_or_default }) or ancestors(#{ branch_name_or_default }))"
102106
"-r '#{ up_to }:#{ after } #{ query }'"
103107
end
104108

105-
["hg log -f -v #{ options }", after]
109+
["hg log -v #{ options }", after]
106110
end
107111
end
108112
end

lib/ohloh_scm/adapters/hg/head.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ class HgAdapter < AbstractAdapter
33
def head_token
44
# This only returns first 12 characters.
55
# How can we make it return the entire hash?
6-
branch_opts = "--rev #{branch_name || :default}"
6+
branch_opts = "--rev #{branch_name_or_default}"
77
token = run("hg id --debug -i -q #{url} #{branch_opts}").strip
88

99
# Recent versions of Hg now somtimes append a '+' char to the token.

lib/ohloh_scm/adapters/hg/misc.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,5 +30,11 @@ def tags
3030
[tag_name, rev, Time.parse(time_string)]
3131
end
3232
end
33+
34+
protected
35+
36+
def branch_name_or_default
37+
branch_name || :default
38+
end
3339
end
3440
end

0 commit comments

Comments
 (0)