Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

9 use gitlab git #102

Merged
merged 20 commits into from
Apr 25, 2017
Merged

9 use gitlab git #102

merged 20 commits into from
Apr 25, 2017

Conversation

eugenk
Copy link
Member

@eugenk eugenk commented Apr 12, 2017

This shall fix #9. As a follow-up, I created #85, #96, #97, #98, #99, #100, #101 and #104 for the next steps.

There are already some library methods for these new issues. Most of them only need to be exposed to the Ontohub API.

This pull request depends on ontohub/ontohub-models#67 for the seeds.

Usage

  • Login with a user:
    http -j POST :3000/users/sign_in user:='{"name": "ada", "password": "changeme"}'
    
    Say, your token is ABCdef123. Then store it in the shell variable TOKEN
    TOKEN="ABCdef123"
    
  • Create a file:
    either with base64 encoding
    http -j POST :3000/ada/repo0/ref/master/tree data:='{"attributes": {"content": "bXkgY29udGVudA==", "encoding": "base64", "commit_message": "add file", "path": "test.txt"}}' "Authorization: Bearer $TOKEN" 
    
    or with plain text:
    http -j POST :3000/ada/repo0/ref/master/tree data:='{"attributes": {"content": "my content", "encoding": "plain", "commit_message": "add file", "path": "test.txt"}}' "Authorization: Bearer $TOKEN" 
    
  • Move a file:
    http -j PATCH :3000/ada/repo0/ref/master/tree/test.txt data:='{"attributes": {"commit_message": "move a file", "path": "moved_test.txt"}}' "Authorization: Bearer $TOKEN"
    
  • Change file contents:
    http -j PATCH :3000/ada/repo0/ref/master/tree/test.txt data:='{"attributes": {"content": "my new content", "encoding": "plain", "commit_message": "change a file"}}' "Authorization: Bearer $TOKEN"
    
  • Get a file (no login required):
    http -j :3000/ada/repo0/ref/master/tree/test.txt
    http -j :3000/ada/repo0/tree/test.txt
    
  • Get a directory (no login required):
    http -j :3000/ada/repo0/ref/master/tree/
    http -j :3000/ada/repo0/tree/
    
  • Delete a file:
    http -j DELETE :3000/ada/repo0/ref/master/tree/test.txt  "Authorization: Bearer $TOKEN"
    

@eugenk eugenk requested review from phyrog and ebolloff April 12, 2017 17:16
@eugenk eugenk force-pushed the 9-use_gitlab_git branch 3 times, most recently from eb12e5a to 3965af0 Compare April 12, 2017 20:50
@eugenk eugenk force-pushed the 9-use_gitlab_git branch from 3965af0 to 64b87bc Compare April 14, 2017 12:38
@eugenk eugenk force-pushed the 9-use_gitlab_git branch 4 times, most recently from 6bd2760 to 4bef0a0 Compare April 18, 2017 07:04
eugenk added 8 commits April 18, 2017 09:41
* Create: http --timeout=3600 -j POST :3000/ada/repo0/ref/master/tree data:='{"attributes": {"content": "aGFuc21laXNlcg==", "encoding": "base64", "commit_message": "do something", "path": "my_test.txt"}}'
* Show: http --timeout=3600 -j GET :3000/ada/repo0/ref/master/tree/my_test.txt
* Rename without content change: http --timeout=3600 -j PATCH :3000/ada/repo0/ref/master/tree/my_test.txt data:='{"attributes": {"commit_message": "do something", "path": "my_test_renamed.txt"}}'
* Rename with content chane: http --timeout=3600 -j PATCH :3000/ada/repo0/ref/master/tree/my_test_renamed.txt data:='{"attributes": {"content": "abc", "encoding": "plain", "commit_message": "do something", "path": "my_test_renamed2.txt"}}'
* Delete: http --timeout=3600 -j DELETE :3000/ada/repo0/ref/master/tree/my_test3.txt
Run all scpes except for the svn-tagged ones with:
```
rspec --tags ~svn
```
@eugenk eugenk force-pushed the 9-use_gitlab_git branch from 4bef0a0 to 6b8587b Compare April 18, 2017 07:42
def wrap(repository)
return repository if repository.is_a?(RepositoryCompound)
unless repository.is_a?(Repository)
raise "Object given to ##{__method__} is not a repository"
Copy link
Contributor

Choose a reason for hiding this comment

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

This line is untested, which is OK, since it is only triggerd when we mess something up during development. So I would wrap this in nocov.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done in 3f08fe2

@collection = klass.where(parent_params).all
@collection = klass.where(parent_params)
if @collection.respond_to?(:all)
@collection = @collection.all
Copy link
Contributor

Choose a reason for hiding this comment

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

This is dead code for now (and untested), it should be used later. Leaving it untested and without nocov should be fine, so we don't forget about it.

@repository = Repository.new(*repository_params)
end

def save
Copy link
Contributor

Choose a reason for hiding this comment

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

This needs a transaction to not leave dead data in the database if creating a repository in the file system fails.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done in 3f08fe2

true
end

def destroy
Copy link
Contributor

Choose a reason for hiding this comment

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

Same as with save. rmtree could fail and leave data in the file system.

@errors.add(:content, 'content must exist')
end
unless content.is_a?(String)
@errors.add(:content, 'content must be a String')
Copy link
Member

Choose a reason for hiding this comment

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

string

it { expect(response).to have_http_status(:ok) }
it { |example| expect([example, response]).to comply_with_api }

it 'moves the file and ' do
Copy link
Member

Choose a reason for hiding this comment

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

and what?

@eugenk eugenk force-pushed the 9-use_gitlab_git branch from 3f08fe2 to 03b7019 Compare April 18, 2017 12:08
@eugenk
Copy link
Member Author

eugenk commented Apr 19, 2017

I added a commit to upgrade to the current gitlab_git (v9.0.5). They changed the committing interface. Most of the added code was taken from the previous version of gitlab_git and restructured a little to fit in with the changes.

@eugenk eugenk force-pushed the 9-use_gitlab_git branch from 56c9e07 to c63fa48 Compare April 19, 2017 07:24
@eugenk eugenk merged commit 21e9779 into master Apr 25, 2017
@eugenk eugenk deleted the 9-use_gitlab_git branch April 25, 2017 06:22
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.

Use gitlab_git
3 participants