Giter VIP home page Giter VIP logo

gitlab-cli's People

Contributors

alromh87 avatar beckje01 avatar carlosen14 avatar chris-morgan avatar daniel-vera-g avatar dependabot-preview[bot] avatar dependabot[bot] avatar holinc19 avatar jamieslome avatar jaybowang avatar lord-y avatar mathroc avatar pierreduchemin avatar renovate-bot avatar stevelacey avatar vishwanatharondekar avatar vishwanathd11 avatar

Stargazers

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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

gitlab-cli's Issues

Feature Request: Assignee support

Hi @vishwanatharondekar, have you considered adding option support for setting the assignee for e.g.

-a, --assignee [optional] Assignee for the merge request

As before happy to test the functionality in our environment.

Thanks,
Damian.

maybe it's not support ssh.

emmm,one day,when i push local branch to remote,this error occurred: could not read Username for 'http://xxx': Device not configured. but when i use ssh ,this error fixed,but this plugin can not work well. so , my problem is if it's true,and can you help me slove this problem.

Print URL after merge-request

It would be nice to print the URL to a successfully created merge request. For example:

$ lab merge-request -t upstream/master
https://gitlab.mycompany.com/my-org/my-app/merge_requests/6

create mr with cli failed: 404 - {"status":"404","error":"Not Found"}

I have already configured the gitlab url and gitlab token first.

lab mr -b test -t develop -m 'merge this test branch to develop branch' -o

Couldn't create merge request
404 - {"status":"404","error":"Not Found"}

below is the verbose log detail:

lab mr -b test -t develop -m 'merge this test branch to develop branch' -o -v

Verbose option used. Detailed logging information will be emitted.

Getting base branch information

Getting base branch name :
Argument provided : test
Base branch name obtained : test

Getting remote of branch : test
Executing git config branch.test.remote
Remote obtained : origin

Getting URL of remote : origin
Executing git config remote.origin.url
URL of remote obtained : [email protected]/tools.git

gitlab host obtained : gitlab.xxx-inc.com

Project name derived from host : xxxx/tools

Getting gitlab project info for : xxx/tools
Base project info obtained : "\r\n\r\n\r\n <meta charset="UTF-8">\r\n <meta http-equiv="X-UA-Compatible" content="IE=edge">\r\n <script src="/home/js/jquery-1.11.3.min.js"></script>\r\n <script src="/home/js/jquery-adapter.js"></script>\r\n <script src="/home/js/common.js?11"></script>\r\n <script src="/home/js/xxxxx-face-login.js"></script>\r\n\r\n\r\n<div id="_umfp" style="width:0px;height:0px;overflow:hidden">\r\n\r\n<form method="post" id="form" action="" >\r\n <input type="hidden" name="action" value="PreLoginAction" />\r\n\t<input type="hidden" name="event_submit_do_PreLogin" value="false" />\r\n <input type="hidden" id="deviceIp" name="deviceIp" value=""/>\r\n <input type="hidden" id="trustEnvToken" name="trustEnvToken" value=""/>\r\n <input type="hidden" id="trustEnvTokenErrorInfo" name="trustEnvTokenErrorInfo" value=""/>\r\n <input type="hidden" name="caLoginKey" value=""/>\r\n <input type="hidden" name="umidTokenId" value="xxxx" >\r\n <input type="hidden" name="disableCert" value="true" >\r\n <input type="hidden" name="alipayFaceMetaInfo" id="xxxyFaceMetaInfo" value="" >\r\n \r\n\r\n<script type="text/javascript">\r\n window.ssoConfig = {\r\n 'sso_csrftoken': 'xxxx',\r\n 'intranet': 'true',\r\n 'ipAddr': 'xxxxx',\r\n }\r\n\r\n try {\r\n var metaInfo = getMetaInfo();\r\n if (metaInfo != undefined) {\r\n $('#alipayFaceMetaInfo').val(JSON.stringify(metaInfo));\r\n }\r\n } catch (e) {\r\n }\r\n\r\n\r\ntry {\r\n var getIpComplete = false;\r\n\tfunction onJSONPCallback(data) {\r\n\t\t$('#deviceIp').val(data.x_forwarded_for);\r\n getIpComplete=true;\r\n\t}\r\n\tGetDeviceIp("https://xxx-xx.xxx-inc.com/ip.js\");\r\n\r\n \tvar trustEnvToken = false;\r\n\tvar trustEnvTokenErrorInfo = {};\r\n function tetCb(data) {\r\n if (data && data.token) {\r\n $('#trustEnvToken').val(data.token);\r\n trustEnvToken=true;\r\n } else {\r\n trustEnvToken=false;\r\n trustEnvTokenErrorInfo = {"readyState": 4, "status": 200, "statusText": "token is blank"};\r\n }\r\n }\r\n var pageLoadTimestamp = new Date().getTime();\r\n\r\n getTrustEnvToken('tetCb', 'xxxx-sso_001', 1, 'xxxxx', pageLoadTimestamp, trustEnvTokenErrorInfo);\r\n\r\n var iIntervalId =setInterval(function(){\r\n var currentTimestamp = new Date().getTime();\r\n if((currentTimestamp-pageLoadTimestamp) &gt; 600 || (getIpComplete &amp;&amp; trustEnvToken)){\r\n clearInterval(iIntervalId);\r\n try {\r\n if (!trustEnvTokenErrorInfo) {\r\n trustEnvTokenErrorInfo = {};\r\n }\r\n\r\n if (!trustEnvToken) {\r\n if (!trustEnvTokenErrorInfo.statusText) {\r\n trustEnvTokenErrorInfo.statusText = "no response, maybe timeout";\r\n }\r\n }\r\n\r\n trustEnvTokenErrorInfo.requestId = 'xxxxxxx';\r\n trustEnvTokenErrorInfo.time = pageLoadTimestamp;\r\n $("#trustEnvTokenErrorInfo").val(JSON.stringify(trustEnvTokenErrorInfo));\r\n } catch (e) {\r\n }\r\n // console.log("errorInfo=" + JSON.stringify(trustEnvTokenErrorInfo))\r\n document.getElementById('form').submit();\r\n }\r\n },50);\r\n} catch (e) {\r\n document.getElementById('form').submit();\r\n}\r\n\r\n</script> \r\n\r\n\r\n<script>\r\n (function (w, d, t) {\r\n var s = d.createElement(t), m = d.getElementsByTagName(t)[0];\r\n s.async = 1;\r\n s.src = "https://g.xxxx.com/sd/pointman/js/pt2.js?_=\" + Math.floor((new Date()).getTime() / 36e5);\r\n m.parentNode.insertBefore(s, m);\r\n\r\n w._pointman_q = w._pointman_q || [];\r\n _pointman_q.push(["um", function (umx) {\r\n var container = document.getElementById("_umfp");\r\n umx.init({\r\n timeout: 3000,\r\n userId: '',\r\n token: 'xxxx',\r\n userFieldId: 'loginAccountInput',\r\n serviceLocation: "cn",\r\n appName: 'buc',\r\n model: 'L1',\r\n containers: {flash: container, dcp: container}\r\n });\r\n }]);\r\n })(window, document, "script");\r\n</script>"

Getting target branch information
Remote branch name obtained : develop

Getting remote of branch : develop
Executing git config branch.develop.remote
Remote obtained : origin

Getting URL of remote : origin
Executing git config remote.origin.url
URL of remote obtained : [email protected]/tools.git

Getting target project information
Target project info obtained : "\r\n\r\n\r\n <meta charset="UTF-8">\r\n <meta http-equiv="X-UA-Compatible" content="IE=edge">\r\n <script src="/home/js/jquery-1.11.3.min.js"></script>\r\n <script src="/home/js/jquery-adapter.js"></script>\r\n <script src="/home/js/common.js?11"></script>\r\n <script src="/home/js/xxx-face-login.js"></script>\r\n\r\n\r\n<div id="_umfp" style="width:0px;height:0px;overflow:hidden">\r\n\r\n<form method="post" id="form" action="" >\r\n <input type="hidden" name="action" value="PreLoginAction" />\r\n\t<input type="hidden" name="event_submit_do_PreLogin" value="false" />\r\n <input type="hidden" id="deviceIp" name="deviceIp" value=""/>\r\n <input type="hidden" id="trustEnvToken" name="trustEnvToken" value=""/>\r\n <input type="hidden" id="trustEnvTokenErrorInfo" name="trustEnvTokenErrorInfo" value=""/>\r\n <input type="hidden" name="caLoginKey" value=""/>\r\n <input type="hidden" name="umidTokenId" value="xxxxx" >\r\n <input type="hidden" name="disableCert" value="true" >\r\n <input type="hidden" name="alipayFaceMetaInfo" id="alipayFaceMetaInfo" value="" >\r\n \r\n\r\n<script type="text/javascript">\r\n window.ssoConfig = {\r\n 'sso_csrftoken': 'xxxxx',\r\n 'intranet': 'true',\r\n 'ipAddr': 'xxxxx',\r\n }\r\n\r\n try {\r\n var metaInfo = getMetaInfo();\r\n if (metaInfo != undefined) {\r\n $('#alipayFaceMetaInfo').val(JSON.stringify(metaInfo));\r\n }\r\n } catch (e) {\r\n }\r\n\r\n\r\ntry {\r\n var getIpComplete = false;\r\n\tfunction onJSONPCallback(data) {\r\n\t\t$('#deviceIp').val(data.x_forwarded_for);\r\n getIpComplete=true;\r\n\t}\r\n\tGetDeviceIp("https://xxx-office.xxxx-inc.com/ip.js\");\r\n\r\n \tvar trustEnvToken = false;\r\n\tvar trustEnvTokenErrorInfo = {};\r\n function tetCb(data) {\r\n if (data && data.token) {\r\n $('#trustEnvToken').val(data.token);\r\n trustEnvToken=true;\r\n } else {\r\n trustEnvToken=false;\r\n trustEnvTokenErrorInfo = {"readyState": 4, "status": 200, "statusText": "token is blank"};\r\n }\r\n }\r\n var pageLoadTimestamp = new Date().getTime();\r\n\r\n getTrustEnvToken('tetCb', 'xxx-sso_001', 1, 'xxxxxx', pageLoadTimestamp, trustEnvTokenErrorInfo);\r\n\r\n var iIntervalId =setInterval(function(){\r\n var currentTimestamp = new Date().getTime();\r\n if((currentTimestamp-pageLoadTimestamp) &gt; 600 || (getIpComplete &amp;&amp; trustEnvToken)){\r\n clearInterval(iIntervalId);\r\n try {\r\n if (!trustEnvTokenErrorInfo) {\r\n trustEnvTokenErrorInfo = {};\r\n }\r\n\r\n if (!trustEnvToken) {\r\n if (!trustEnvTokenErrorInfo.statusText) {\r\n trustEnvTokenErrorInfo.statusText = "no response, maybe timeout";\r\n }\r\n }\r\n\r\n trustEnvTokenErrorInfo.requestId = 'xxxxxx';\r\n trustEnvTokenErrorInfo.time = pageLoadTimestamp;\r\n $("#trustEnvTokenErrorInfo").val(JSON.stringify(trustEnvTokenErrorInfo));\r\n } catch (e) {\r\n }\r\n // console.log("errorInfo=" + JSON.stringify(trustEnvTokenErrorInfo))\r\n document.getElementById('form').submit();\r\n }\r\n },50);\r\n} catch (e) {\r\n document.getElementById('form').submit();\r\n}\r\n\r\n</script> \r\n\r\n\r\n<script>\r\n (function (w, d, t) {\r\n var s = d.createElement(t), m = d.getElementsByTagName(t)[0];\r\n s.async = 1;\r\n s.src = "https://g.xxx.com/sd/pointman/js/pt2.js?_=\" + Math.floor((new Date()).getTime() / 36e5);\r\n m.parentNode.insertBefore(s, m);\r\n\r\n w._pointman_q = w._pointman_q || [];\r\n _pointman_q.push(["um", function (umx) {\r\n var container = document.getElementById("_umfp");\r\n umx.init({\r\n timeout: 3000,\r\n userId: '',\r\n token: 'xxxx',\r\n userFieldId: 'loginAccountInput',\r\n serviceLocation: "cn",\r\n appName: 'buc',\r\n model: 'L1',\r\n containers: {flash: container, dcp: container}\r\n });\r\n }]);\r\n })(window, document, "script");\r\n</script>"

Getting merge request title. Argument provided : merge this test branch to develop branch
Title obtained with -m option: merge this test branch to develop branch
Merge request title : merge this test branch to develop branch

Creating merge request
Couldn't create merge request
404 - {"status":"404","error":"Not Found"}

Invocation after installation fails

Installed using command: npm install git-lab-cli -g

How was it fixed (note that the command without --global as mentioned on your site doesn't work):
git config --global --add gitlab.url ""
git config --global --add gitlab.token ""

Opened up new terminal and tried command: lab --help

Expected Behavior:

C:\Users\sshaik>lab --help
Usage: index [options] [command]

gitlab command line utility

Options:
  -V, --version                 output the version number
  -h, --help                    output usage information

Commands:
  browse [options]              Open current branch page in gitlab
  compare [options]             Open compare page between two branches
  merge-request|mr [options]    Create merge request on gitlab
  merge-requests|mrs [options]  Opens merge requests page for the repo

Actual Behavior:

C:\Users\sshaik>lab --help
'true' is not recognized as an internal or external command,
operable program or batch file.
child_process.js:656
    throw err;
    ^

Error: Command failed: git config --get gitlab.url || true
'true' is not recognized as an internal or external command,
operable program or batch file.

    at checkExecSyncError (child_process.js:616:11)
    at execSync (child_process.js:653:13)
    at Object.get (C:\Users\sshaik\AppData\Roaming\npm\node_modules\git-lab-cli\options.js:11:16)
    at C:\Users\sshaik\AppData\Roaming\npm\node_modules\git-lab-cli\options.js:21:23
    at Object.<anonymous> (C:\Users\sshaik\AppData\Roaming\npm\node_modules\git-lab-cli\options.js:55:5)
    at Module._compile (internal/modules/cjs/loader.js:701:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:712:10)
    at Module.load (internal/modules/cjs/loader.js:600:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:539:12)
    at Function.Module._load (internal/modules/cjs/loader.js:531:3)
    at Module.require (internal/modules/cjs/loader.js:637:17)
    at require (internal/modules/cjs/helpers.js:22:18)
    at Object.<anonymous> (C:\Users\sshaik\AppData\Roaming\npm\node_modules\git-lab-cli\index.js:15:15)
    at Module._compile (internal/modules/cjs/loader.js:701:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:712:10)
    at Module.load (internal/modules/cjs/loader.js:600:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:539:12)
    at Function.Module._load (internal/modules/cjs/loader.js:531:3)
    at Function.Module.runMain (internal/modules/cjs/loader.js:754:12)
    at startup (internal/bootstrap/node.js:283:19)
    at bootstrapNodeJSCore (internal/bootstrap/node.js:622:3)

Would be great if we can have option to list merge requests

It'd be great to show open merge requests assigned to the user, or an option to list all of them currently opened.
gitlab-cli list-merge-request open or gitlab-cli list-merge-request assigned something like this.
What are your thoughts on it ? Happy to provide PR for this. ๐ŸŽ‰

"Cannot read property 'iid' of undefined" on create merge request

Hi,
I tried to run the create-merge-request command but I got this error:

 /usr/local/lib/node_modules/gitlab-cli/index.js:415
                  if (mergeRequestResponse.iid) {
                                          ^

TypeError: Cannot read property 'iid' of undefined
at /usr/local/lib/node_modules/gitlab-cli/index.js:415:47
at /usr/local/lib/node_modules/gitlab-cli/node_modules/gitlab/lib/ApiBaseHTTP.js:90:22
at _Class.wrap_response (/usr/local/lib/node_modules/gitlab-cli/node_modules/slumber/lib/API.js:192:18)
at _Class.wrap_response (/usr/local/lib/node_modules/gitlab-cli/node_modules/slumber/lib/API.js:4:59)
at Request._callback (/usr/local/lib/node_modules/gitlab-cli/node_modules/slumber/lib/API.js:265:24)
at Request.self.callback (/usr/local/lib/node_modules/gitlab-cli/node_modules/request/request.js:188:22)
at emitTwo (events.js:106:13)
at Request.emit (events.js:191:7)
at Request.<anonymous> (/usr/local/lib/node_modules/gitlab-cli/node_modules/request/request.js:1171:10)
at emitOne (events.js:96:13)

Do you know what the problem might be?
Thanks

Merge request not opening on correct repository.

I have two repositories in my organization:
https://gitlab.com/kassellabs/videomatik
https://gitlab.com/kassellabs/videomatik-sample

When I try to open a merge request using lab merge-request on videomatik repository, it's opening the merge request on the videomatik-sample repository. As it doesn't have the branch it just opens an empty merge request.

It may be related to something in the code that may use the URL prefix instead of the entire URL.
I did check if my remote is correct, and everything is correct.

The lab merge-requests command works fine, open the merge requests of the correct repo.

Why succed when baseBranch is not defined?

I am having this issue, this runs on gitlab pipeline, it couldn't create the mr but it exits 0 ..

ORIGIN_BRANCH dev
TARGET_BRANCH staging
$ npx [email protected] merge-request --base "origin/$ORIGIN_BRANCH" --target "origin/$TARGET_BRANCH" --message "AUTOMATIC MERGE REQUEST FROM PIPELINE $ORIGIN_BRANCH > $TARGET_BRANCH" --labels "pipeline,automr,deploy,$TARGET_BRANCH" --print
npx: installed 103 in 13.781s
Couldn't create merge request
baseBranch is not defined # this is supposed to exit 1 to assume this couldn't make it
#
#
Job succeeded 

Project info fetch failed : TypeError: Cannot read property 'headers' of undefined

lab browse
works for me without any problem.

However, when executing
lab create-merge-request -v -b "some_branch" -t "some_branch" -m 'some_message'

the output is:

Project info fetch failed : TypeError: Cannot read property 'headers' of undefined

I am using GitLab Community Edition 8.17.8 and gitlab-cli version 1.0.2.
If I change gitlab.url to some non-existing host, the result is the same.
Additionally, -v option does not print anything more (it should print request and response).

My gitlab server contains multiple projects organised in multiple groups.
gitlab.url points to the root path of the server (like "https://gitlab.yourcompany.com")
I also configured gitlab.token.

Compare option also fails:
lab compare -v -b "feature/abc" -t "develop"

Getting base branch name :
Argument provided : feature/abc
Branch name obtained : feature/abc
Base branch name obtained : feature/abc

Getting remote of branch : feature/abc
Branch name obtained : feature/abc
Executing git config branch.feature/abc.remote
Remote obtained : origin

Getting URL of remote : origin
Executing git config remote.origin.url
URL of remote obtained : git@my_gitlab_server:some_group/some-project.git

Project info fetch failed : TypeError: Cannot read property 'headers' of undefined`

Error: self signed certificate in certificate chain

Hi! Just trying out lab and I'm getting a cert validation error.

$ lab merge-request
Project info fetch failed : RequestError: Error: self signed certificate in certificate chain

The certs in use are signed by my company's CA, and I have the necessary certs installed to trust that CA (/etc/pki/ca-trust). My browsers and other command line tools are honoring that, but it seems the HTTP package gitlab-cli is using is failing to trust that CA.

Any ideas? Thanks!

Oh yeah, I'm on Fedora 29.

Automatically merge if CI passes

Adding an option to automatically merge to master if the merge request passes CI (it's possible on via the web interface)

Thanks

Regular Expression Issue

I am currently facing one problem
My git link is https://www.company.com/cool/new-project/sample.git

The expected name of the project should be cool/new-project/sample.git
but the regular expression only cut it to new-project/sample.git
Then the server return 404

Would it be possible that the project name can be passed by parameter or modify the regular expression so the project name can be used?

Crash when using with pipelines

readlineSync asks for input gitlab url and token, but it crashes when using in gitlab pipelines.

Maybe adding a param so you don't ask for that when running on pipeline.

error is:

stty: invalid argument '-f'
/root/.npm/_npx/35/lib/node_modules/git-lab-cli/node_modules/readline-sync/lib/read.sh: line 49: can't create /dev/tty: No such device or address

lab command just hanging on

I missed installation for global config and it's always hanging on. Yeah, it's some kinda minor issue, but seem you could make it more friendly.

Trying to run lab and lab merge-request --help:

0 kirby-pc 07:39:43 /d/home
โœ“ $ lab

130 kirby-pc 08:00:37 /d/home
โœ— $ lab merge-request --help

130 kirby-pc 08:02:34 /d/home
โœ— $

Error while creating MR

Hello All,

I am getting below error while creating MR
Error occured :
{ Error: Command failed: git config branch.DisabledTest.remote
at ChildProcess.exithandler (child_process.js:275:12)
at emitTwo (events.js:126:13)
at ChildProcess.emit (events.js:214:7)
at maybeClose (internal/child_process.js:925:16)
at Process.ChildProcess._handle.onexit (internal/child_process.js:209:5)
killed: false,
code: 1,
signal: null,
cmd: 'git config branch.DisabledTest.remote' }

when i use lab browse ,there are some problem.

lab browse (this my command)

Error occured :
{ Error: Command failed: git config branch.release_vn_lua2_auto_convert_json_to_lua.remote

at ChildProcess.exithandler (child_process.js:273:12)
at ChildProcess.emit (events.js:180:13)
at maybeClose (internal/child_process.js:936:16)
at Socket.stream.socket.on (internal/child_process.js:353:11)
at Socket.emit (events.js:180:13)
at Pipe._handle.close [as _onclose] (net.js:541:12)

killed: false,
code: 1,
signal: null,
cmd: 'git config branch.release_vn_lua2_auto_convert_json_to_lua.remote' }

Not compat w ssh config file

URL of remote obtained: my_ssh_config_alias:project/repo.git
gitlab host obtained: git.company.com

Remote at which branch_x is tracked is not a gitlab repository at git.company.com

Name stuff like hub

You're copying hub, it's great, I think this should be more like it โ€“ I tweaked my install like so:

  • #42 renamed gitlab-cli to lab โ€“ either way I think dropping the cli would be better, of course it's cli
  • #40 renamed create-merge-request to merge-request (consistent with pull-request)
  • #40 renamed open-merge-requests to merge-requests (hub doesn't have this afaik)

Also these would be good:

  • #39 use the git default editor when message is not specified โ€“ not the system default editor
  • print out the url of created merge requests rather than opening them
    edit: notice this is an option but not default, I'd vote for consistent default but /shrug
  • #41 load project envs
  • infer the gitlab url from the origin remote (you'd still need to collect the token though so no biggie I guess)

You might also want to consider renaming the project and emphasising the completeness / compatibility with hub more โ€“ I went through 2 or 3 alternative gitlab-cli or cli-gitlab projects that didn't work before I got to this one

Great work thanks ๐Ÿ˜ โœŒ๏ธ


Edit: I decided to get off my ass and PR some of the above โ˜๏ธ

[question] getting base & target branches

I usually have my repositories setup like this:

$ git remote -v
origin  ssh://[email protected]:222/me/project.git (fetch)
origin  ssh://[email protected]:222/me/project.git (push)
upstream        ssh://[email protected]:222/source/project.git (fetch)
upstream        ssh://[email protected]:222/source/project.git (push)
$ cat .git/config
[branch "my-branch"]
        remote = upstream
        merge = refs/heads/master

when I run gitlab-cli create-merge-request -v

I get an error saying:

Source project is not a fork of the target project

I have to specify both the base and the target. I have a wrapper that does this :

gitlab-cli create-merge-request -p -b origin/$(git rev-parse --abbrev-ref HEAD) -t upstream/master "@$"

is it the expected behavior ? can this be improved to automatically get the correct branch by default ? (the behavior of https://github.com/jsmits/github-cli seems sane)

Print by default

I think the -p option should be default for all commands, and there should be a flag for opening

The merge-requests command could actually be made to work like hub issue in that by default it uses the API to list out merge requests (on that note lab issue would be handy too)

Afaik most tools require you do something like open $(echo 'http://example.com') to open, i.e. they don't support it internally

Afaik this wouldn't break any BC in CI's given they'll be using the -p flag which can still be supported even though it's default and redundant

Re-factor code into smaller modules

When I started writing this utility. Didn't expect it to grow like it has now. Will want to re-factor the code into smaller modules so maintenance / enhancements will not be a pain.

License ISC or MIT

You list 2 licenses, ISC in package.json and MIT in LICENSE, presumably you want one or the other

MR cannot be created if multiple remotes are defined

If multiple remotes are defined on the project, the tool fails to detect the default target branch via the git config branch.master.remote command.

This also occurs if the specific config value is not set.

Workarounds are:

  • explicitly specify the target remote and branch via -t origin/master.

`getURLOfRemote` return a remote URL with newline character after the project name

The returned value remoteURL contains a newline character in one of my projects.
When I run yarn lab mrs, the value is like https://git.mycompany.com/me/my-project%0A/merge_requests. There's a %0A after the project name.

But it's OK in another project. Don't know why.

gitlab-cli/index.js

Lines 193 to 208 in 1a94539

function getURLOfRemote(remote) {
logger.log('\nGetting URL of remote : ' + remote);
var promise = new Promise(function (resolve/*, reject*/) {
logger.log('Executing ', 'git config remote.' + remote.trim() + '.url');
exec('git config remote.' + remote.trim() + '.url', { cwd: projectDir }, function (error, remoteURL/*, stderr*/) {
if (error) {
console.error(colors.red('Error occured :\n') , colors.red(error));
process.exit(1);
}
logger.log('URL of remote obtained : ' + remoteURL.green);
resolve(remoteURL);
});
});
return promise;
}

Error when I try to make merge request

When I try to make merge request:

$ gitlab-cli create-merge-request -b feature/GAS-1179/roundRatings -t release/1.0.0
/usr/local/lib/node_modules/gitlab-cli/index.js:358
          var defaultBranch = project.default_branch;
                                     ^

TypeError: Cannot read property 'default_branch' of null
    at /usr/local/lib/node_modules/gitlab-cli/index.js:358:38
    at /usr/local/lib/node_modules/gitlab-cli/node_modules/gitlab/lib/Models/Projects.js:139:20
    at /usr/local/lib/node_modules/gitlab-cli/node_modules/gitlab/lib/ApiBaseHTTP.js:86:22
    at Function._Class.wrap_response (/usr/local/lib/node_modules/gitlab-cli/node_modules/slumber/lib/API.js:192:18)
    at Function.wrap_response (/usr/local/lib/node_modules/gitlab-cli/node_modules/slumber/lib/API.js:4:59)
    at Request._callback (/usr/local/lib/node_modules/gitlab-cli/node_modules/slumber/lib/API.js:215:26)
    at Request.self.callback (/usr/local/lib/node_modules/gitlab-cli/node_modules/request/request.js:188:22)
    at emitTwo (events.js:125:13)
    at Request.emit (events.js:213:7)
    at Request.<anonymous> (/usr/local/lib/node_modules/gitlab-cli/node_modules/request/request.js:1171:10)

Gitlab Fork support - provide remotes in the branch name

I have a Gitlab repo (origin) that is forked from another Gitlab repo (upstream). Both repos have a branch called develop.

upstream/develop -> forked -> origin/develop -> cloned develop to my laptop.

I make changes in my clone and push to origin. Then I generate a merge request from origin/develop to upstream/develop.

Can the tool be used to generate a merge request for this? i.e something like

gitlab-cli create-merge-request -b origin/develop -t upstream/develop

Thanks in advance.
Damian.

How do I need to set the project name

Hi, good job @vishwanathd11
The problem arises because the default project name is not the one I want

lab merge-request -t equator -m aa -v

got: gitlab.com:nova_dubai/first-web.git // The first of all my projects
want: gitlab.com:nova_dubai/first.git

Thanks

Verbose option used. Detailed logging information will be emitted.



Getting base branch information

Getting base branch name : 
Executing git rev-parse --abbrev-ref HEAD
Base branch name obtained : master

Getting remote of branch : master
Executing git config branch.master.remote
Remote obtained : origin


Getting URL of remote : origin
Executing  git config remote.origin.url
URL of remote obtained : [email protected]:nova_dubai/first.git


gitlab host obtained : gitlab.com

Project name derived from host : nova_dubai/first

Getting gitlab project info for : nova_dubai/first
Base project info obtained : {"id":32506476,"description":"","name":"ๅˆทๅ•ๅŽๅฐ","name_with_namespace":"nova_dubai / ๅˆทๅ•ๅŽๅฐ","path":"first-web","path_with_namespace":"nova_dubai/first-web","created_at":"2022-01-02T13:11:59.643Z","default_branch":"main","tag_list":[],"topics":[],"ssh_url_to_repo":"[email protected]:nova_dubai/firit","http_url_to_repo":"https://gitlab.com/nova_dubai/first-web.git","web_url":"https://gitlab.com/nova_dubai/first-web","readme_url":null,"avatar_url":null,"forks_count":0,"star_count":0,"last_activity_at":"2022-01-15T23:23:36.075Z","namespace":{"id":12048031,"name":"nova_dubai","path":"nova_dubai","kind":"group","full_path":"nova_dubai","parent_id":null,"avatar_url":null,"web_url":"https://gitlab.com/groups/nova_dubai"},"container_registry_image_prefix":"registry.gitlab.com/nova_dubai/first-web","_links":{"self":"https://gitlab.com/api/v4/projects/32506476","issues":"https://gitlab.com/api/v4/projects/32506476/issues","merge_requests":"https://gitlab.com/api/v4/projects/32506476/merge_requests","repo_branches":"https://gitlab.com/api/v4/projects/32506476/repository/branches","labels":"https://gitlab.com/api/v4/projects/32506476/labels","events":"https://gitlab.com/api/v4/projects/32506476/events","members":"https://gitlab.com/api/v4/projects/32506476/members"},"packages_enabled":true,"empty_repo":true,"archived":false,"visibility":"private","resolve_outdated_diff_discussions":false,"container_expiration_policy":{"cadence":"1d","enabled":false,"keep_n":10,"older_than":"90d","name_regex":".*","name_regex_keep":null,"next_run_at":"2022-01-03T13:11:59.661Z"},"issues_enabled":true,"merge_requests_enabled":true,"wiki_enabled":true,"jobs_enabled":true,"snippets_enabled":true,"container_registry_enabled":true,"service_desk_enabled":true,"service_desk_address":"contact-project+nova-dubai-first-web-32506476-issue-@incoming.gitlab.com","can_create_merge_request_in":true,"issues_access_level":"enabled","repository_access_level":"enabled","merge_requests_access_level":"enabled","forking_access_level":"enabled","wiki_access_level":"enabled","builds_access_level":"enabled","snippets_access_level":"enabled","pages_access_level":"private","operations_access_level":"enabled","analytics_access_level":"enabled","container_registry_access_level":"enabled","emails_disabled":null,"shared_runners_enabled":true,"lfs_enabled":true,"creator_id":713145,"import_status":"none","open_issues_count":0,"ci_default_git_depth":50,"ci_forward_deployment_enabled":true,"ci_job_token_scope_enabled":false,"public_jobs":true,"build_timeout":3600,"auto_cancel_pending_pipelines":"enabled","build_coverage_regex":null,"ci_config_path":"","shared_with_groups":[],"only_allow_merge_if_pipeline_succeeds":false,"allow_merge_on_skipped_pipeline":null,"restrict_user_defined_variables":false,"request_access_enabled":true,"only_allow_merge_if_all_discussions_are_resolved":false,"remove_source_branch_after_merge":true,"printing_merge_request_link_enabled":true,"merge_method":"merge","squash_option":"default_off","suggestion_commit_message":null,"merge_commit_template":null,"squash_commit_template":null,"auto_devops_enabled":false,"auto_devops_deploy_strategy":"continuous","autoclose_referenced_issues":true,"keep_latest_artifact":true,"external_authorization_classification_label":"","requirements_enabled":false,"security_and_compliance_enabled":true,"compliance_frameworks":[],"permissions":{"project_access":null,"group_access":{"access_level":30,"notification_level":null}}}



Getting target branch information
Remote branch name obtained : equator

Getting remote of branch : equator
Executing git config branch.equator.remote
Remote obtained : origin


Getting URL of remote : origin
Executing  git config remote.origin.url
URL of remote obtained : [email protected]:nova_dubai/first.git

Getting target project information
Target project info obtained : {"id":32506476,"description":"","name":"ๅˆทๅ•ๅŽๅฐ","name_with_namespace":"nova_dubai / ๅˆทๅ•ๅŽๅฐ","path":"first-web","path_with_namespace":"nova_dubai/first-web","created_at":"2022-01-02T13:11:59.643Z","default_branch":"main","tag_list":[],"topics":[],"ssh_url_to_repo":"[email protected]:nova_dubai/f.git","http_url_to_repo":"https://gitlab.com/nova_dubai/first-web.git","web_url":"https://gitlab.com/nova_dubai/first-web","readme_url":null,"avatar_url":null,"forks_count":0,"star_count":0,"last_activity_at":"2022-01-15T23:23:36.075Z","namespace":{"id":12048031,"name":"nova_dubai","path":"nova_dubai","kind":"group","full_path":"nova_dubai","parent_id":null,"avatar_url":null,"web_url":"https://gitlab.com/groups/nova_dubai"},"container_registry_image_prefix":"registry.gitlab.com/nova_dubai/first-web","_links":{"self":"https://gitlab.com/api/v4/projects/32506476","issues":"https://gitlab.com/api/v4/projects/32506476/issues","merge_requests":"https://gitlab.com/api/v4/projects/32506476/merge_requests","repo_branches":"https://gitlab.com/api/v4/projects/32506476/repository/branches","labels":"https://gitlab.com/api/v4/projects/32506476/labels","events":"https://gitlab.com/api/v4/projects/32506476/events","members":"https://gitlab.com/api/v4/projects/32506476/members"},"packages_enabled":true,"empty_repo":true,"archived":false,"visibility":"private","resolve_outdated_diff_discussions":false,"container_expiration_policy":{"cadence":"1d","enabled":false,"keep_n":10,"older_than":"90d","name_regex":".*","name_regex_keep":null,"next_run_at":"2022-01-03T13:11:59.661Z"},"issues_enabled":true,"merge_requests_enabled":true,"wiki_enabled":true,"jobs_enabled":true,"snippets_enabled":true,"container_registry_enabled":true,"service_desk_enabled":true,"service_desk_address":"contact-project+nova-dubai-first-web-32506476-issue-@incoming.gitlab.com","can_create_merge_request_in":true,"issues_access_level":"enabled","repository_access_level":"enabled","merge_requests_access_level":"enabled","forking_access_level":"enabled","wiki_access_level":"enabled","builds_access_level":"enabled","snippets_access_level":"enabled","pages_access_level":"private","operations_access_level":"enabled","analytics_access_level":"enabled","container_registry_access_level":"enabled","emails_disabled":null,"shared_runners_enabled":true,"lfs_enabled":true,"creator_id":713145,"import_status":"none","open_issues_count":0,"ci_default_git_depth":50,"ci_forward_deployment_enabled":true,"ci_job_token_scope_enabled":false,"public_jobs":true,"build_timeout":3600,"auto_cancel_pending_pipelines":"enabled","build_coverage_regex":null,"ci_config_path":"","shared_with_groups":[],"only_allow_merge_if_pipeline_succeeds":false,"allow_merge_on_skipped_pipeline":null,"restrict_user_defined_variables":false,"request_access_enabled":true,"only_allow_merge_if_all_discussions_are_resolved":false,"remove_source_branch_after_merge":true,"printing_merge_request_link_enabled":true,"merge_method":"merge","squash_option":"default_off","suggestion_commit_message":null,"merge_commit_template":null,"squash_commit_template":null,"auto_devops_enabled":false,"auto_devops_deploy_strategy":"continuous","autoclose_referenced_issues":true,"keep_latest_artifact":true,"external_authorization_classification_label":"","requirements_enabled":false,"security_and_compliance_enabled":true,"compliance_frameworks":[],"permissions":{"project_access":null,"group_access":{"access_level":30,"notification_level":null}}}

Getting merge request title. Argument provided : aa
Title obtained with -m option: aa
Merge request title : aa
Merge request description : undefined


Creating merge request
Merge request response: 

 {
  id: 135356651,
  iid: 3,
  project_id: 32506476,
  title: 'aa',
  description: null,
  state: 'opened',
  created_at: '2022-01-15T23:53:25.458Z',
  updated_at: '2022-01-15T23:53:25.458Z',
  merged_by: null,
  merged_at: null,
  closed_by: null,
  closed_at: null,
  target_branch: 'equator',
  source_branch: 'master',
  user_notes_count: 0,
  upvotes: 0,
  downvotes: 0,
  author: {
    id: 9114706,
    username: 'Naist4869',
    name: 'Naist4869',
    state: 'active',
    avatar_url: 'https://secure.gravatar.com/avatar/0f0f86d6a5dc99ca7bc0231d78ed1cd4?s=80&d=identicon',
    web_url: 'https://gitlab.com/Naist4869'
  },
  assignees: [],
  assignee: null,
  reviewers: [],
  source_project_id: 32506476,
  target_project_id: 32506476,
  labels: [],
  draft: false,
  work_in_progress: false,
  milestone: null,
  merge_when_pipeline_succeeds: false,
  merge_status: 'checking',
  sha: null,
  merge_commit_sha: null,
  squash_commit_sha: null,
  discussion_locked: null,
  should_remove_source_branch: null,
  force_remove_source_branch: false,
  reference: '!3',
  references: { short: '!3', relative: '!3', full: 'nova_dubai/first-web!3' },
  web_url: 'https://gitlab.com/nova_dubai/first-web/-/merge_requests/3',
  time_stats: {
    time_estimate: 0,
    total_time_spent: 0,
    human_time_estimate: null,
    human_total_time_spent: null
  },
  squash: false,
  task_completion_status: { count: 0, completed_count: 0 },
  has_conflicts: false,
  blocking_discussions_resolved: true,
  approvals_before_merge: null,
  subscribed: true,
  changes_count: null,
  latest_build_started_at: null,
  latest_build_finished_at: null,
  first_deployed_to_production_at: null,
  pipeline: null,
  head_pipeline: null,
  diff_refs: null,
  merge_error: null,
  user: { can_merge: false }
}


Move npm package to gitlab-cli

With reference to discussion on #38 (comment)
I contacted the owner of https://www.npmjs.com/package/gitlab-cli . He is ready to transfer the ownership if we will keep the backward compatibility.

Need to evaluate the options.

  1. Move all the code in this repository supporting the commands going ahead as well.
  2. Do a major version change on gitlab-cli and then declaring that original commands are no more supported in the new version. Install with 1.x for getting original gitlab-cli. (Not sure if owner will be okay with this, sent him email asking about this)

Can't run in sub-directories of repo

If we try to use the command in any of the sub-directories like git command.
It fails due to failure to save PULL_REQUEST_TITLE file in the editor.

One of the solution can be to get the base directory of the repo before running the command.
Another solution is to create the file at current directory and do cleanup after command is done.

Cannot read property 'log' of null

Issue

$ gitlab-cli browse
/usr/local/lib/node_modules/gitlab-cli/index.js:70
  logger.log('\nGetting base branch name');
        ^

TypeError: Cannot read property 'log' of null
    at getBaseBranchName (/usr/local/lib/node_modules/gitlab-cli/index.js:70:9)
    at browse (/usr/local/lib/node_modules/gitlab-cli/index.js:138:3)
    at Command.<anonymous> (/usr/local/lib/node_modules/gitlab-cli/index.js:366:5)
    at Command.listener (/usr/local/lib/node_modules/gitlab-cli/node_modules/commander/index.js:301:8)
    at emitTwo (events.js:106:13)
    at Command.emit (events.js:191:7)
    at Command.parseArgs (/usr/local/lib/node_modules/gitlab-cli/node_modules/commander/index.js:615:12)
    at Command.parse (/usr/local/lib/node_modules/gitlab-cli/node_modules/commander/index.js:458:21)
    at Object.<anonymous> (/usr/local/lib/node_modules/gitlab-cli/index.js:385:9)
    at Module._compile (module.js:571:32)
Running on OSX, installed using 

$ npm install https://github.com/vishwanatharondekar/gitlab-cli.git -g

$  uname -a
Darwin doneill-mbp 15.6.0 Darwin Kernel Version 15.6.0: Wed Nov  2 20:30:56 PDT 2016; root:xnu-3248.60.11.1.2~2/RELEASE_X86_64 x86_64


$ git --version
git version 2.11.0

$ npm -v
4.0.5

$ node -v
v7.4.0

Both GITLAB_URL and GITLAB_TOKEN set.

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.