desktop / dugite Goto Github PK
View Code? Open in Web Editor NEWElegant bindings for working with Git in your Node applications
License: MIT License
Elegant bindings for working with Git in your Node applications
License: MIT License
Not sure how to get more specific information than process.platform
when installing, but it'd be nice as an experiment to detect flavours of Ubuntu and fail for older version.
Some of our error regexes include captures, but they aren't actually passed up and out to consumers. We should do that, though it'll require some refactoring of errors.
Currently dugite supports only 3 platforms(Windows, Linux and OSX). Requesting to support FreeBSD as well. I will submit a pull request if you guys are ready to incorporate.
I'm doing some cross compilation stuff for GHD and the usage of process.platform at build time in https://github.com/desktop/dugite/blob/master/script/config.js isn't great for that.
JS/Node isn't my usual cup of tea so I might be doing something dumb here but this works! On GHD I just replaced all instances of process.platform with this:
function getTargetPlatform () {
const platform = process.env.TARGET_PLATFORM || process.platform
if(platform != 'darwin' && platform != 'win32') {
console.error(`Exiting - I'm not set up to work on ${platform} yet! :(`)
process.exit(1)
}
return platform
}
Which lets me build like: TARGET_PLATFORM=win32 npm run build:dev
Could we do something like that here as well or is there a better way to override process.platform?
Relates to #43
Goals:
I am trying to use dugite
with the local git executable if available, if not, simply fall back to the one shipped with your library.
I already have some logic that tries to locate the executable. Let assume, it works correctly on all platforms, and it returns with /usr/local/bin/git
in my case. When I set the executable path to the LOCAL_GIT_DIRECTORY
environment variable, then the resolveGitBinary
function in the git-environment
module appends the bin/git
to the path. The execution obviously fails, because git is not available under /usr/local/bin/git/bin/git
.
Is there a way to avoid doing that? It would be great, to have an option to set a LOCAL_GIT_PATH
variable too (or something similar), and if that is present, use that without any modifications. Or did I completely misunderstand how to configure and use a custom git executable from dugite
?
Any feedbacks are much appreciated! Cheers.
For commands that generate a lot of output, it is hard to anticipate an adequate buffer size. I think it would be cool if there was an equivalent spawn() method in GitProcess that worked like child_process.spawn and allowed reading unlimited output streams.
Git is installed, but am unable to use dugite in an electron-renderer process.
Git could not be found. This is most likely a problem in dugite itself
This should:
I have problems when I am trying to bundle my electron application with dugite
. I do not know whether this is a dugite
issue or an electron-builder
one.
I have forked a boilerplate electron application and added dugite
as a dependency. It works as expected when I start the application from the source with: npm i && npm start
.
The problem occurs when I am bundling it. As I see, ASAR does not handle symlinks properly, so I have configured "asar": false
. When I am running my bundler task with npm run release
, it does not fail but it logs the following error. Is it safe to just ignore it?
Unhandled rejection Error: ENOENT: no such file or directory, symlink 'git' -> '/Users/akos.kitta/Desktop/electron-boilerplate/dist/mac/Electron.app/Contents/Resources/app/node_modules/dugite/git/libexec/git-core/git-check-ignore'
at /Users/akos.kitta/Desktop/electron-boilerplate/node_modules/electron-builder/src/util/appFileCopier.ts:70:38
From previous event:
at /Users/akos.kitta/Desktop/electron-boilerplate/node_modules/electron-builder/src/util/appFileCopier.ts:70:21
at Generator.next (<anonymous>)
at xfs.mkdir.er (/Users/akos.kitta/Desktop/electron-boilerplate/node_modules/fs-extra-p/node_modules/fs-extra/lib/mkdirs/mkdirs.js:37:14)
at FSReqWrap.oncomplete (fs.js:137:15)
From previous event:
at copyAppFiles (/Users/akos.kitta/Desktop/electron-boilerplate/node_modules/electron-builder/out/util/appFileCopier.js:62:21)
at taskManager.addTask.default.each.it (/Users/akos.kitta/Desktop/electron-boilerplate/node_modules/electron-builder/src/platformPackager.ts:238:86)
From previous event:
at MacPackager.copyAppFiles (/Users/akos.kitta/Desktop/electron-boilerplate/node_modules/electron-builder/src/platformPackager.ts:238:43)
at /Users/akos.kitta/Desktop/electron-boilerplate/node_modules/electron-builder/src/platformPackager.ts:186:10
at Generator.next (<anonymous>)
at runCallback (timers.js:785:20)
at tryOnImmediate (timers.js:747:5)
at processImmediate [as _immediateCallback] (timers.js:718:5)
From previous event:
at MacPackager.doPack (/Users/akos.kitta/Desktop/electron-boilerplate/node_modules/electron-builder/out/platformPackager.js:267:11)
at /Users/akos.kitta/Desktop/electron-boilerplate/node_modules/electron-builder/src/macPackager.ts:87:71
at Generator.next (<anonymous>)
From previous event:
at MacPackager.pack (/Users/akos.kitta/Desktop/electron-boilerplate/node_modules/electron-builder/out/macPackager.js:183:11)
at /Users/akos.kitta/Desktop/electron-boilerplate/node_modules/electron-builder/src/packager.ts:260:24
From previous event:
at Packager.doBuild (/Users/akos.kitta/Desktop/electron-boilerplate/node_modules/electron-builder/out/packager.js:332:11)
at /Users/akos.kitta/Desktop/electron-boilerplate/node_modules/electron-builder/src/packager.ts:186:52
at Generator.next (<anonymous>)
From previous event:
at Packager.build (/Users/akos.kitta/Desktop/electron-boilerplate/node_modules/electron-builder/out/packager.js:261:11)
at /Users/akos.kitta/Desktop/electron-boilerplate/node_modules/electron-builder/src/builder.ts:283:40
at Generator.next (<anonymous>)
From previous event:
at build (/Users/akos.kitta/Desktop/electron-boilerplate/node_modules/electron-builder/out/builder.js:63:21)
at then (/Users/akos.kitta/Desktop/electron-boilerplate/node_modules/electron-builder/src/cli/cli.ts:49:4)
at runCallback (timers.js:785:20)
at tryOnImmediate (timers.js:747:5)
at processImmediate [as _immediateCallback] (timers.js:718:5)
From previous event:
at Object.args [as handler] (/Users/akos.kitta/Desktop/electron-boilerplate/node_modules/electron-builder/src/cli/cli.ts:49:4)
at Object.runCommand (/Users/akos.kitta/Desktop/electron-boilerplate/node_modules/yargs/lib/command.js:228:22)
at Object.parseArgs [as _parseArgs] (/Users/akos.kitta/Desktop/electron-boilerplate/node_modules/yargs/yargs.js:1041:24)
at Object.get [as argv] (/Users/akos.kitta/Desktop/electron-boilerplate/node_modules/yargs/yargs.js:957:21)
at Object.<anonymous> (/Users/akos.kitta/Desktop/electron-boilerplate/node_modules/electron-builder/src/cli/cli.ts:43:15)
at Module._compile (module.js:612:30)
at Object.Module._extensions..js (module.js:623:10)
at Module.load (module.js:531:32)
at tryModuleLoad (module.js:494:12)
at Function.Module._load (module.js:486:3)
at Function.Module.runMain (module.js:653:10)
at startup (bootstrap_node.js:187:16)
at bootstrap_node.js:608:3
Probably you have quite good experience with both electron and dugite after putting GitHub Desktop
together, so I thought, it worth asking here.
Steps to reproduce:
mkdir electron-dugite-tmp \
&& cd electron-dugite-tmp \
&& git clone https://github.com/kittaakos/electron-boilerplate.git \
&& cd electron-boilerplate \
&& npm i \
&& npm run release
Thank you!
Hello,
When trying to install dugite on Android, I get this error:
yarn add v1.3.2
info No lockfile found.
[1/4] Resolving packages...
[2/4] Fetching packages...
[3/4] Linking dependencies...
[4/4] Building fresh packages...
[1/1] ⠠ dugite
[-/1] ⠐ waiting...
[-/1] ⠐ waiting...
[-/1] ⠐ waiting...
error /data/data/com.termux/files/home/node_modules/dugite: Command failed.
Exit code: 1
Command: node ./script/download-git.js
Arguments:
Directory: /data/data/com.termux/files/home/node_modules/dugite
Output:
/data/data/com.termux/files/home/node_modules/dugite/script/config.js:32
const index = pathName.lastIndexOf('/')
^
TypeError: Cannot read property 'lastIndexOf' of null
at getConfig (/data/data/com.termux/files/home/node_modules/dugite/script/config.js:32:26)
at Object.<anonymous> (/data/data/com.termux/files/home/node_modules/dugite/script/download-git.js:11:35)
at Module._compile (module.js:635:30)
at Object.Module._extensions..js (module.js:646:10)
at Module.load (module.js:554:32)
at tryModuleLoad (module.js:497:12)
at Function.Module._load (module.js:489:3)
This is because process.platform == 'android'
.
I don't expect you to provide an ARM Android binary but I understand we can use another Git binary with GIT_EXEC_PATH
, so I guess the install script could just ignore the download (maybe with a warning) when on Android.
Installing the dugite package from npm fails on Windows. It works fine on Linux though.
It seams to be an error with how the checksum is being calculated in the download-git.js
script. I have checked and the expected checksum matches what is posted on the dugite-native releases page.
Here is the console output when attempting to install v1.49.0
PS H:\> npm install dugite
> [email protected] postinstall H:\node_modules\dugite
> node ./script/download-git.js
Validation failed. Expected 'a54b64be0976c3f919a52d4dd6dcfb9434744072860df980767d662275a9f235' but got 'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855'
Downloading Git from: https://github.com/desktop/dugite-native/releases/download/v2.15.0-rc1/dugite-native-v2.15.0-win32
-25.tar.gz
Error raised while downloading https://github.com/desktop/dugite-native/releases/download/v2.15.0-rc1/dugite-native-v2.1
5.0-win32-25.tar.gz { Error: connect ETIMEDOUT 192.30.253.113:443
at Object._errnoException (util.js:1024:11)
at _exceptionWithHostPort (util.js:1046:20)
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1182:14)
code: 'ETIMEDOUT',
errno: 'ETIMEDOUT',
syscall: 'connect',
address: '192.30.253.113',
port: 443 }
npm WARN enoent ENOENT: no such file or directory, open 'H:\package.json'
npm WARN !invalid#1 No description
npm WARN !invalid#1 No repository field.
npm WARN !invalid#1 No README data
npm WARN !invalid#1 No license field.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] postinstall: `node ./script/download-git.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] postinstall script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\z0039cjb\AppData\Roaming\npm-cache\_logs\2017-11-17T08_36_18_434Z-debug.log
It also happens with v1.48.0
PS H:\test> npm install [email protected]
> [email protected] postinstall H:\test\node_modules\dugite
> node ./script/download-git.js
Validation failed. Expected 'db14ddc1281606b001a44b70f2fc3deda6e60686de06d135056205216c2a5663' but got 'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855'
Downloading Git from: https://github.com/desktop/dugite-native/releases/download/v2.14.3-rc1/dugite-native-v2.14.3-win32
-23.tar.gz
Error raised while downloading https://github.com/desktop/dugite-native/releases/download/v2.14.3-rc1/dugite-native-v2.1
4.3-win32-23.tar.gz { Error: connect ETIMEDOUT 192.30.253.113:443
at Object._errnoException (util.js:1024:11)
at _exceptionWithHostPort (util.js:1046:20)
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1182:14)
code: 'ETIMEDOUT',
errno: 'ETIMEDOUT',
syscall: 'connect',
address: '192.30.253.113',
port: 443 }
npm WARN enoent ENOENT: no such file or directory, open 'H:\test\package.json'
npm WARN test No description
npm WARN test No repository field.
npm WARN test No README data
npm WARN test No license field.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] postinstall: `node ./script/download-git.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] postinstall script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\z0039cjb\AppData\Roaming\npm-cache\_logs\2017-11-17T08_43_27_174Z-debug.log
I haven't tested with older versions.
I ran into this problem when installing the npm packages needed for GitHub Desktop on my Windows 7 x64 machine. I later tried this on my Ubuntu 17.10 x64 setup and it installed without errors.
error: GH001: Large files detected.
error: GH002: Sorry, branch or tag names consisting of 40 hex characters are not allowed.
error: GH003: Sorry, force-pushing to %s is not allowed.
error: GH005: Sorry, refs longer than %d bytes are not allowed.
error: GH006: Protected branch update failed for %d
... and it works as expected both when I use the executable with dugite
and when I use child_process
. Maybe it is not the appropriate channel to ask for help, but I was unable to clone any public repositories (without required authentication) when I set the LOCAL_GIT_DIRECTORY
environment variable. Does anyone have a pointer what am I doing wrong? Any help would be greatly appreciated.
Here a very stupid simple module that does the cloning with both dugite
and with the child_process
.
index.js
const fs = require('fs');
const path = require('path');
const gp = require('dugite').GitProcess;
const cp = require('child_process');
getVersionWithDugite();
cloneWithDugite('https://github.com/desktop/dugite.git');
process.env.LOCAL_GIT_DIRECTORY = '/usr/local/';
getVersionWithDugite();
cloneWithDugite('https://github.com/desktop/what-the-changelog.git');
getVersionWithChildProcess();
cloneWithChildProcess('https://github.com/desktop/dugite-native.git');
function getVersionWithDugite() {
gp.exec(['--version']).then(result => {
console.log("_____________________");
console.log("OUT", result.stdout.trim());
console.log("ERR", result.stderr.trim());
console.log("_____________________");
});
}
function cloneWithDugite(url) {
gp.exec(['clone', url]).then(result => {
console.log("_____________________");
console.log("OUT", result.stdout.trim());
console.log("ERR", result.stderr.trim());
console.log("_____________________");
});
}
function getVersionWithChildProcess() {
cp.execFile('/usr/local/bin/git', ['--version'], (error, stdout, stderr) => {
console.log('stdout', stdout)
console.log('stderr', stderr)
});
}
function cloneWithChildProcess(url) {
cp.execFile('/usr/local/bin/git', ['clone', url], (error, stdout, stderr) => {
console.log('stdout', stdout)
console.log('stderr', stderr)
});
}
package.json
{
"name": "dugite-clone",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "kittaakos <[email protected]>",
"license": "ISC",
"dependencies": {
"dugite": "^1.39.0"
}
}
Translations should include both title and description, and I'm not really fussed about how we surface this to the callers.
cc @joshaber as we talked about this today
to ensure I don't break anything
would be cool
Revert this change 483c20f, correct the typo and address the regexes that currently violate this rule.
A Linux user might have an existing certificate bundle defined which is good enough for Git.
We shouldn't do this work if the environment variable is already set.
The repro is loosely related to initializing a repository with it's own commit, and then connecting it to a local repository with it's own distinct commit, and then trying to git pull
.
$ git pull
error: unable to merge unrelated histories
Make this a first class error.
If you're using dugite on Linux but want to use an external Git, you won't have the dugite-native
distribution and it's CA bundle available. This means this file might not exist on disk.
If a LOCAL_GIT_DIRECTORY
is defined as per #85, we should not set GIT_SSL_CAINFO
and instead assume the user has their GIT_SSL_CAINFO
environment variable set to point to their own bundle.
The ability to fire off Git builds from source for the platforms we currently support and generate standalone packages, wherever upstream binaries are unavailable.
No need to do this for Windows as Git for Windows publishes a 64-bit MinGit with each release.
To ensure repeatable builds, perhaps something like Docker images so that installed dependencies and flags to make
are documented and version controlled.
Support an environment variable that lets users override the bundled binaries with an external git binary that they've built elsewhere. This provides advanced users an escape hatch to use on older Linux distributions than we support, as opposed to them just being SOL.
We'd have to be careful to specify the git version we expect -- part of the benefit of using git-kitchen-sink is not having to worry about compatibility with older git versions, after all. Maybe include the git version in the environment variable name?
As suggested in desktop/dugite-native#13 (comment).
cc @kuychaco
Git would return a 128 for a git fetch
- I wish i'd kept the output so we can map this to a proper error code when it does happen.
I use a commit hook that does git grep -P
, i.e. uses Perl regexps which is a compile time dependency. This works everywhere but Atom's git support, where it fails because that git is built without it.
It seems that just about everyone else compiles with pcre. Short list of git versions we use where this works:
Having an embedded git, while convenient, should follow mainstream git as closely as possible in my opinion. And PCRE in turn is probably the "mainstream RE" these days and not some esoteric option.
I've taken to telling people who use Atom to simply remove the dugite git-core, forcing it to use system, but this seems sub-optimal if you guys are relying on the behaviors of a fixed version. Eliminating the grep -P is non-trivial.
Attempting to delete a protected branch is blocked as expected. Perhaps we could make the error message a little more readable?
repro:
tested in v1.0.5beta0, mac
Logs in console:
install.ts:31 Executing checkRemoteBranchExistence: git -c credential.helper= ls-remote --heads origin dupe (took 1.363s)
install.ts:31 Executing deleteRemoteBranch: git -c credential.helper= push origin :dupe (took 2.324s)
install.ts:23 `git -c credential.helper= push origin :dupe` exited with an unexpected code: 1.
remote: error: GH006: Protected branch update failed for refs/heads/dupe.
remote: error: Cannot delete a protected branch
To https://github.com/tierninho-tester/trterdgdfgdf.git
! [remote rejected] dupe (protected branch hook declined)
error: failed to push some refs to 'https://github.com/tierninho-tester/trterdgdfgdf.git'
error @ install.ts:23
t.git @ core.ts:175```
One example - configuration like user.name
and user.email
isn't necessarily checked in the context of a repository. execFile
also doesn't require a cwd
option.
Should we make it optional?
Continuing from https://github.com/atom/git-kitchen-sink/pull/31#discussion_r81224928.
It's currently not exported to consumers and we don't use it internally. So we should either 🔥 it or export it.
npm run test:external
.npm run test
would run the external tests besides the fast
and slow
tests.test/external
.When reverting a commit I got an error message that looks to include double "hints" even though it appears to be one sentence.
I believe it should read:
error: Reverting is not possible because you have unmerged files.
hint: Fix them up in the work tree, and then use 'git add/rm <file>',
as appropriate, to mark resolution and make a commit.
fatal: revert failed
1.0.11-beta0, mac
Ref:
desktop/desktop#3579
It looks like this is coming from git itself:
https://github.com/git/git/blob/7668cbc60578f99a4c048f8f8f38787930b8147b/advice.c#L106-L107
https://github.com/git/git/blob/7668cbc60578f99a4c048f8f8f38787930b8147b/advice.c#L48-L65
So to customize this we'd need to parse this error in dugite.
This is a bit tricky to do currently as it's all private repos currently, but here's some inspiration:
https://github.com/electron/chromedriver/blob/master/download-chromedriver.js
Git for Windows publishes it's releases artifacts on GitHub releases - any shortcuts for macOS @joshaber?
This would let CI environments download the dugite-native
packages to a location of their choosing, for caching purposes
Is there any plan to improve emebed git's excute performance especially on windows system ?
It runs too slowlier rather than the git version which installed locally.
So I have been wondering how does dugite resolve the the git executable path.
From what I have seen in the code; if given, it uses either the GIT_EXEC_PATH or the LOCAL_GIT_DIRECTORY, which after reading the documentation I am not sure what is the difference between them?
My problem is when the library is not given any of the above vars, how does it resolve the git executable path?
I am wondering this, because when I included the library in my app and ran git config --list both my email and name were configured already. How does this happen if dugite is using its own installation of git? What happens if there is no local install of git because as far as I know git won't commit without a name and email setup. Thanks!
Hi there,
I found the dugite
library very useful, lightweight and convenient. I've read a thread why it is better to use dugite
instead of using nodegit
.
In the desktop
code base, you have already implemented a lot of git commands with the corresponding models, which is awesome.
Unfortunately, I was unable to figure out a way to use them in my code. I assume it is not published to npm yet or I must be blind. Also, in some places, I can see UI dependency in the model code which should not harm for instance a backend application (that we are working on) but it does not either make much sense. So our plan is to create an npm package that contains dugite
(as an upstream npm dependency) and the stripped down version of the commands and models you guys have been working. And redistribute it under MIT license.
Could you guys give me some feedback whether
desktop
commands and models in a downstream npm package. (Please note, we cannot have a dependency on electron
.)Thanks for your effort so far and in advance for your feedback!
relevant Git output (with an exit code of 1)
...
remote: Resolving deltas: 100% (4/4), completed with 4 local objects.
remote: error: GH007: Your push would publish a private email address.
remote: You can make your email public or disable this protection by visiting:
remote: http://github.com/settings/emails
...
We need to bump the release URLs and the checksums to the latest release for each platform. Stop doing this manually.
Perhaps we can change the error dialogue to something more understandable to the layman? and do we need some validation on the url field? I entered some jiberish in the url field and got this:
1.0.11-beta0, mac
related to: desktop/desktop#3539
Dugite seems to be similar to Nodegit (https://github.com/nodegit/nodegit) in that it provides an API to interact with git.
Could you explain the differences and/or why you decided to work on dugite?
That is something I have accidentally overlooked here.
The findGit
call should be wrapped in a try-catch
block.
I will take care of this.
So I figured out why updates are broken.
On macOS, we have to remove a quarantine attribute from newly downloaded files. That requires that the files be owner-writable.
But it turns out the following files aren't writable, for whatever reason. They were in a previous version of git-kitchen-sink, but no mas.
git/lib/perl5/site_perl/Git/I18N.pm
git/lib/perl5/site_perl/Git/IndexInfo.pm
git/lib/perl5/site_perl/Git/SVN/Editor.pm
git/lib/perl5/site_perl/Git/SVN/Fetcher.pm
git/lib/perl5/site_perl/Git/SVN/GlobSpec.pm
git/lib/perl5/site_perl/Git/SVN/Log.pm
git/lib/perl5/site_perl/Git/SVN/Memoize/YAML.pm
git/lib/perl5/site_perl/Git/SVN/Migration.pm
git/lib/perl5/site_perl/Git/SVN/Prompt.pm
git/lib/perl5/site_perl/Git/SVN/Ra.pm
git/lib/perl5/site_perl/Git/SVN/Utils.pm
git/lib/perl5/site_perl/Git/SVN.pm
git/lib/perl5/site_perl/Git.pm
So at minimum, we need to chmod
these files so they're writable. But I'm wondering if we even need these? It kinda looks like they're a Perl API that we wouldn't care about. So maybe we can just throw a NO_PERL=1
on the build script?
@shiftkey 💰 for your thoughts?
otherwise a clean install fails on subsequent calls to npm within the same script 🙌
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.