Showing posts with label Git. Show all posts
Showing posts with label Git. Show all posts

Tuesday, January 8, 2013

简单的 p4wrapper 实现 perforce p4的edit和revert命令

公司用Perforce管理代码,因为有很多产品,每个产品在自己的branch里面,电脑上自己参与的产品都有一个独立的workspace。自己用SourceInsight和SublimeText2来编辑代码,每次都在不同的workspace间换来换去,所以如果用p4命令来check out代码,P4_CLIENT每次都在变。为了省事,自己用Go写了一个简单的p4的wrapper,只做两件事情,check out和revert。其余的perforce的工作就用GUI的客户端。

自己写的这个wrapper有考虑到本人自己的情况,所以这个wrapper不需要用户去定义现在的workspace,wrapper会通过比较现在的工作文件的绝对路径和用户在当前开发主机上的所有workspace的路径mapping比较找出working workspace。这样就省去了每次要定义P4_CLIENT的苦恼。

代码放在github上, 点这里

我也把自己用的SublimeText 2的plugin放上去了。希望对那些工作环境跟我差不多的人有所帮助。

Thursday, August 23, 2012

个人第一个github项目

今天终于在github上有了一个真正的自己的项目,虽然是一个很简单,很小的项目,不过还是值得纪念一下。

项目地址: https://github.com/yongzhy/goploticus

这个是libploticus的Go语言封装。

ploticus的主页

A free, GPL, non-interactive software package for producing plots, charts, and graphics from data. It was developed in a Unix/C environment and runs onvarious Unix, Linux, and win32 systems. ploticus is good for automated or just-in-time graph generation, handles date and time data nicely, and has basic statistical capabilities. It allows significant user control over colors, styles, options and details. Ploticus is a mature package, available since 1999, and version 2.40 has more than 12,000 downloads to date. Ploticus was discussed in this 2008 review on Linux.com.

因为是第一次封装C的API,折腾了一阵子才发现要让cgo编译代码,import “C” 必须是单独一行.

可以编辑的代码:

  1. //#cgo LDFLAGS: -lploticus

  2. //#include <libploticus.h>

  3. //#include <stdlib.h>

  4. import "C"

不可以被编辑的代码:

  1. //#cgo LDFLAGS: -lploticus

  2. //#include <libploticus.h>

  3. //#include <stdlib.h>

  4. import (

  5. "C"

  6. )

什么东西,都要试了才真正知道。

Thursday, June 14, 2012

开始用 GitHub


现在免费的代码托管最出名的非Github莫属,但是我一直没有用Github,原因是因为Github没有免费的Private Repo。我之前一直是使用bitbucket的服务,可以有无限的私有Repo。最近因为学习目的,要fork一个Repo来看看,就开始使用Github。

Github有很详细的说明,我这里只是记录下来不让自己忘。
在做下面步骤之前,一定是要先安装git的。

$ git config --global user.name "myname"
$ git config --global user.email "myname@T420_Win"

make the git cache username and password for 1 hour (default is 15 mins), so you
don't need to type username and password everytime talk to remote server.

$ git config --global credential.helper 'cache --timeout=3600'

fork a repo

clone the forked repo
$ git clone git@github.com:username/Spoon-Knife.git

$ cd Spoon-Knife

Assigns the original repo to a remote called "upstream"
$ git remote add upstream git://github.com/octocat/Spoon-Knife.git

Pull the changes not present in your local repository, without modify your files
$ git fetch upstream

Pushes commits to your remote repo stored on GitHub
$ git push origin master

Fetches any new changes from the original repo and Merges any changes fetched into your working files
$ git fetch upstream

$ git merge upstream/master