Skip to content

Conversation

@timcheadle
Copy link
Contributor

Capistrano 3 no longer produces a REVISION file, but instead uses revisions.log in the directory above Rails.root. This fix pulls the release info from the last line of that new file format.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rails.root should be project_root here, please

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also, I'm not a Capistrano user, but this blog post suggests the revisions.log file lives right in the application root?

@timcheadle
Copy link
Contributor Author

Oops, I originally used project_root but it was overwritten in some testing copypasta. =)

As for the location of revisions.log, it's definitely in the Capistrano application root. That blog post has it right:

Capistrano used to create a #{app_path}/current/REVISION file that contained the current 41 character git revision string. If your capistrano tasks or application code depends on this file, make sure you change it to accommodate the new default capistrano process. The data still exists, but it is now stored at #{app_path}/revisions.log

app_path is the root of all releases, not one particular release.

~$ ls -l ~/apps/marketing/
total 144816
lrwxrwxrwx 1 ubuntu ubuntu        51 Jan 27 20:42 current -> /home/ubuntu/apps/marketing/releases/20160127203556
drwxrwxr-x 7 ubuntu ubuntu      4096 Jan 27 20:42 releases
drwxrwxr-x 7 ubuntu ubuntu      4096 Nov  2 22:13 repo
-rw-rw-r-- 1 ubuntu ubuntu      2988 Jan 27 20:42 revisions.log
drwxrwxr-x 7 ubuntu ubuntu      4096 Dec  9 19:12 shared
~$ tail -n3 ~/apps/marketing/revisions.log
Branch staging deployed as release 20160127161603 by faye;
Branch staging deployed as release 20160127162901 by tim;
Branch staging deployed as release 20160127203556 by tim;

@seanlinsley
Copy link
Contributor

We're using Capistrano 3.4.0, and revisions.log exists in the Capistrano deploy directory, but the REVISION file still exists in the Rails root.

/var/www/(app name)# tail revisions.log 
Branch master (at d474cc0) deployed as release 2016012(trunc) by (person)
Branch master (at 5f18r0a) deployed as release 2016012(trunc) by (person)
Branch master (at 02lb58f) deployed as release 2016012(trunc) by (person)
Branch master (at a5d9jf2) deployed as release 2016012(trunc) by (person)
Branch master (at 9dobfa6) deployed as release 2016012(trunc) by (person)
Branch master (at d227284) deployed as release 2016012(trunc) by (person)
Branch master (at 62e7f4d) deployed as release 2016012(trunc) by (person)
Branch master (at 2363e6e) deployed as release 2016012(trunc) by (person)
Branch master (at 9ah63e4) deployed as release 2016012(trunc) by (person)
Branch master (at 9681b74) deployed as release 2016012(trunc) by (person)
/var/www/(app name)# cat current/REVISION
9681b74

@seanlinsley
Copy link
Contributor

Can you link to documentation that explains why, and for what versions this change is necessary?

@timcheadle
Copy link
Contributor Author

Here's the documentation about Capistrano's file structure; there's no mention of REVISION anymore:

http://capistranorb.com/documentation/getting-started/structure/

I couldn't find anything in the official documentation talking about the removal of REVISION, but this blog post makes it pretty clear:

http://building.wanelo.com/2014/03/31/capistrano-you-have-changed.html

Can you find the specific message in your deploy log output that writes the REVISION file? We're using Capistrano 3.0.1 and I definitely don't see it.

@timcheadle
Copy link
Contributor Author

Nevermind, I found it. It looks like REVISION was added back in v3.2.0:

capistrano/capistrano@b1cbb0c#diff-aa4465f31474e46370f8f1f204f7d51eR204

Changelog here:
https://github.com/capistrano/capistrano/blob/master/CHANGELOG.md#320

Diff with previous version:
capistrano/capistrano@v3.1.0...v3.2.0

File.read(File.join(project_root, 'REVISION')).strip rescue nil
version = File.read(File.join(project_root, 'REVISION')).strip rescue nil

# Capistrano 3+
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you could please change this comment to reflect your research (3.0 and 3.1 only I guess?)

@nateberkopec
Copy link
Contributor

Just a quick change to that comment and I think this can be merged

@timcheadle
Copy link
Contributor Author

All done. Thanks!

@nateberkopec
Copy link
Contributor

@timcheadle sorry, can you squash this into a single commit too? gotta keep our git history (relatively) clean

@timcheadle
Copy link
Contributor Author

All done.

@nateberkopec
Copy link
Contributor

Thanks!

nateberkopec added a commit that referenced this pull request Feb 5, 2016
Detect release from Capistrano 3 revisions.log
@nateberkopec nateberkopec merged commit 0cf458e into getsentry:master Feb 5, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants