Code Monkey home page Code Monkey logo

gitlabr's Introduction

CRAN_Status_Badge CRAN\ Downloads\ Badge

gitlabr

Installation

You can install the most recent stable version from CRAN using:

install.packages("gitlabr")

To install the development version using devtools), type:

library(devtools)
install_github("jirkalewandowski/gitlabr")

See the CONTRIBUTING.md for instructions on how to run tests locally and contributor information.

Recommended Gitlab versions

Gitlab 11.6 or higher is generally recommended when using gitlabr version 1.1.6 or higher. This gitlabr version uses the gitlab API v4, older versions of Gitlab using API v3 are still supported by gitlabr 0.9, see details section "API version" of the documentation of gl_connection on how to use them. From gitlabr 1.1.6 on API v3 is deprecated and will no longer be tested or maintained, although it is still present in the code. Also within API v4, changes have been made to the gitlab API, most notably for gitlabr, the session endpoint was removed. The versions of gitlabr will always be tested on the corresponding gitlab version, i.e. gitlabr 1.1.6 works best with gitlab 11.6. However, not for every nwe gitlab version there will be a gitlabr version.

Quick Start Example

R code using gitlabr to perform some easy, common gitlab actions can look like this:

library(gitlabr)

# connect as a fixed user to a gitlab instance
my_gitlab <- gl_connection("https://test-gitlab.points-of-interest.cc",
                           private_token = readLines("secrets/gitlab_token.txt"))
# a function is returned
# its first argument is the request (name or function), optionally followed by parameters

my_gitlab(gl_list_projects) # a data_frame is returned, as is always by gitlabr functions

my_gitlab(gl_list_files, project = "testor")

# create a new issue
new_feature_issue <- my_gitlab(gl_new_issue, project = "testor", "Implement new feature")

# requests via gitlabr always return data_frames, so you can use all common manipulations
require(dplyr)
example_user <-
  my_gitlab("users") %>%
    filter(username == "testuser")

# assign issue to a user
my_gitlab(gl_assign_issue, project = "testor",
          new_feature_issue$iid,
          assignee_id = example_user$id)

my_gitlab(gl_list_issues, "testor", state = "opened")

# close issue
my_gitlab(gl_close_issue, project = "testor", new_feature_issue$iid)$state

Further information

gitlabr's People

Contributors

jirkalewandowski avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

gitlabr's Issues

I have found and fixed an error in function:gl_push_file(), check it out!!

hi,
this is my first time submit an issue.
If I do anything wrong, please just let me know.

Error in gl_push_file()

When I push a file (e.g. csv) to parent directory in project, it works fine!!
But it will get some error when I push a file in sub-directory. following is a simple example code

# first connect to ur project
my_project <- gl_project_connection(gitlab_url, project, private_token)

# push a file to parent directory, look careful to parameter file_path
my_project(gl_push_file, file_path = "upload_to_parent_dir.csv", content, commit_message)
> this can work

# push a file to sub-directory
my_project(gl_push_file, file_path = "folder/upload_to_sub_dir.csv", content, commit_message)
> this will fail

Reason and How to fix

The reason that cause this error is "reserved character" (e.g. "/").
One way to fix this problem is to transfer your file_path by URLencoding().

new_file_path  <- URLencode(URL = "folder/upload_to_sub_dir.csv", reserved = T)

# push a file to sub-directory
my_project(gl_push_file, file_path = new_file_path  , content, commit_message)
> success!!

p.s. "/"p.s. "/" will become "%2F" after URLencoding.


However, other functions in gitlabr can work fine, even not transfer though URLencoding.

my_project(gl_file_exists, file_path = "folder/upload_to_sub_dir.csv", ref = "master")
> this can work

my_project(gl_file_exists, file_path = "folder%2Fupload_to_sub_dir.csv", ref = "master")
> this fail

Therefore, I suggest that gitlabr should unify the usage of "file_path" parameter !!


Moreover, if you try to push the same file multiple times by using "overwrite = T" in gl_push_file().
Here comes up another problem.

# first push, success
new_file_path  <- URLencode(URL = "folder/upload_to_sub_dir.csv", reserved = T)
my_project(gl_push_file, file_path = new_file_path  , content, commit_message)

# push again to overwrite, fail!!!!
new_file_path  <- URLencode(URL = "folder/upload_to_sub_dir.csv", reserved = T)
my_project(gl_push_file, file_path = new_file_path  , content, commit_message)

# change preserved character back, success
my_project(gl_push_file, file_path = "folder/upload_to_sub_dir.csv," content, commit_message)

so, I look the code in gl_push_file(), and I think the problem is in httr::PUT and httr::POST.

for now, if you want to push the same file multiple times, I have a temporarily solution.

file_exist <- my_project(gl_file_exists, file_path, ref)
if (file_exist) new_file_path <- URLdecode(URL = file_path)
else new_file_path <- file_path

my_project(gl_push_file, file_path = new_file_path , content, commit_message)

That's all. Hope my suggestion can give some help~

sincerely, Steve

GitLab 11.11 introduced "multiple assignees" to the "merge_requests" concept

Actual Results

Since GitLab introduced "multiple assignees" as of version 11.11, gitlabr runs intro trouble when "unpacking" a request such as the following (dummy URL is used):

my_gitlab <- gl_connection("https://self-hosted-gitlab.example.com/", private_token = readLines("secrets/gitlab_token.txt"))
gl_merge_requests <- my_gitlab(c("projects", 42, "merge_requests"))

gitlabr outputs this error message:

Error: Column names `assignees.id`, `assignees.name`, `assignees.username`, `assignees.state`, `assignees.avatar_url`, ... (and 1 more) must not be duplicated.

When I looked at the API endpoint for that project on my own GitLab server, I found at least one merge request that had more than 1 user in the "assignees" branch of the JSON response.

Expected results

I'd expect gitlabr to do some sensible data wrangling of "multiple assignees" instead of tripping up and throwing an error.

Extra

GitLab's notes on Multiple Assignees in Merge Requests:

https://docs.gitlab.com/ee/user/project/merge_requests/#multiple-assignees-starter

wrong API session endpoint in recent Gitlab versions

Hi,

when trying to connect to gitlab version 10.5.4, gitlabr looks for the URL

[22/Nov/2018:16:00:32 +0100] "POST //api/v4//session HTTP/1.1" 404 25 "" "libcurl/7.55.1 r-curl/3.2 httr/1.3.1"

According to the Gitlab API doc there is no session endpoint . It was removed in version 10.2.0

image

could you please make gitlabr use private token for recent gitlab versions?

Thanks,
Arnau

Inconsitency with gl_file_exists, gl_get_file & gl_proj_req. Bug in gl_push_file

Hello,

I think there is a difference in behaviour between gl_file_exists, gl_get_file & gl_proj_req. The first function needs file_path as text while the others need it as URL encoded text, like the Gitlab API.

Because gl_push_file calls both gl_file_exists and gl_proj_req, it is impossible to push an existing file that is not in the root of the repository.

I have made the following change in gl_push_file to bypass the problem:

exists <- gl_file_exists(project = project, file_path %>% URLdecode(), ref = branch, ...)

But I think gl_file_exists should be consistent with the other functions.

Documentation when using via gitlab.com

I'm trying to use gitlabr with my repo. But I find it just hangs. I've created a key, with full access, and have tried

# Just hangs
my_gitlab <- gl_connection("https://gitlab.com",tok)
my_gitlab(gl_list_projects)

and

my_gitlab <- gl_connection("https://gitlab.com/csgillespie",tok)
my_gitlab(gl_list_projects)
Error: All columns in a tibble must be 1d or 2d objects:
* Column `node` is externalptr
* Column `doc` is externalptr

I suspect I'm missing something.

Bugs with the function `gl_connection`

I search the old issue and don't find the answer, so I open a new one.

I get this error.

Error in vapply(elements, encode, character(1)) : values must be length 1, but FUN(X[[1]]) result is length 49

I use gl_connection to build a gitlabr function to connect my employer's service.
I read the readme and find the argument private_token input is lines by read_lines.
I open my ..ssh folder, the private ssh key looks like]

-----BEGIN RSA PRIVATE KEY-----
...
-----END RSA PRIVATE KEY-----

I try to delete the head and tail lines but the error message happens again.

I think maybe the error results from the wrong way to input the ssh key.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.